├── .bazelignore ├── .bazelproject ├── .bazelrc ├── .bazelversion ├── .clang-format ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .git-blame-ignore-revs ├── .github ├── CODEOWNERS ├── DISCUSSION_TEMPLATE │ ├── nodejs_api_request.yml │ └── python_package_request.yml ├── ISSUE_TEMPLATE │ ├── runtime-apis.md │ └── workers-types.md ├── secret_scanning.yml └── workflows │ ├── _bazel.yml │ ├── cla.yml │ ├── daily-release.yml │ ├── deps-updater.yml │ ├── fixup.yml │ ├── internal-build.yml │ ├── issues.yml │ ├── labels.yml │ ├── lint.yml │ ├── release-python-runtime.yml │ ├── release.yml │ ├── semgrep.yml │ └── test.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc.json ├── .ruff.toml ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .zed └── settings.json ├── BUILD.bazel ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile.release ├── LICENSE ├── MODULE.bazel ├── README.md ├── RELEASE.md ├── SECURITY.md ├── WORKSPACE ├── build-releases.sh ├── build ├── BUILD.ada-url ├── BUILD.all_pyodide_wheels ├── BUILD.nbytes ├── BUILD.pyodide ├── BUILD.pyodide_packages ├── BUILD.simdutf ├── BUILD.sqlite3 ├── BUILD.wpt ├── BUILD.zlib ├── capnp_embed.bzl ├── cc_ast_dump.bzl ├── ci.bazelrc ├── config │ └── BUILD.bazel ├── deps │ ├── BUILD │ ├── build_deps.jsonc │ ├── dep_pyodide.bzl │ ├── deps.jsonc │ ├── deps.schema.json │ ├── formatters │ │ └── BUILD │ ├── gen │ │ ├── build_deps.bzl │ │ ├── dep_ada_url.bzl │ │ ├── dep_aspect_rules_esbuild.bzl │ │ ├── dep_aspect_rules_js.bzl │ │ ├── dep_aspect_rules_ts.bzl │ │ ├── dep_bazel_skylib.bzl │ │ ├── dep_brotli.bzl │ │ ├── dep_build_bazel_apple_support.bzl │ │ ├── dep_buildifier_darwin_amd64.bzl │ │ ├── dep_buildifier_darwin_arm64.bzl │ │ ├── dep_buildifier_linux_amd64.bzl │ │ ├── dep_buildifier_linux_arm64.bzl │ │ ├── dep_buildifier_windows_amd64.bzl │ │ ├── dep_capnp_cpp.bzl │ │ ├── dep_cargo_bazel_linux_arm64.bzl │ │ ├── dep_cargo_bazel_linux_x64.bzl │ │ ├── dep_cargo_bazel_macos_arm64.bzl │ │ ├── dep_cargo_bazel_macos_x64.bzl │ │ ├── dep_cargo_bazel_win_x64.bzl │ │ ├── dep_clang_format_darwin_arm64.bzl │ │ ├── dep_clang_format_linux_amd64.bzl │ │ ├── dep_clang_format_linux_arm64.bzl │ │ ├── dep_com_google_benchmark.bzl │ │ ├── dep_kj_rs.bzl │ │ ├── dep_ruff_darwin_arm64.bzl │ │ ├── dep_ruff_linux_amd64.bzl │ │ ├── dep_ruff_linux_arm64.bzl │ │ ├── dep_rules_nodejs.bzl │ │ ├── dep_rules_python.bzl │ │ ├── dep_rules_rust.bzl │ │ ├── dep_rules_shell.bzl │ │ ├── dep_simdutf.bzl │ │ ├── dep_ssl.bzl │ │ ├── dep_workerd_cxx.bzl │ │ ├── dep_wpt.bzl │ │ ├── deps.bzl │ │ └── shared_deps.bzl │ ├── requirements.in │ ├── requirements.txt │ ├── shared_deps.jsonc │ ├── update-deps.py │ └── v8.bzl ├── eslint_test.bzl ├── fixtures │ ├── BUILD.bazel │ └── kj_test.sh ├── http.bzl ├── js_capnp_library.bzl ├── js_file.bzl ├── kj_test.bzl ├── lint.bazelrc ├── perfetto │ └── perfetto_cfg.bzl ├── pyodide_bucket.bzl ├── python │ ├── packages_20240829_4.bzl │ └── packages_20250324_1.bzl ├── python_metadata.bzl ├── run_binary_target.bzl ├── rust_toolchains.bzl ├── typescript.bzl ├── wd_capnp_library.bzl ├── wd_cc_benchmark.bzl ├── wd_cc_binary.bzl ├── wd_cc_capnp_library.bzl ├── wd_cc_library.bzl ├── wd_js_bundle.bzl ├── wd_rust_binary.bzl ├── wd_rust_capnp_library.bzl ├── wd_rust_crate.bzl ├── wd_test.bzl ├── wd_ts_bundle.bzl ├── wd_ts_project.bzl ├── wd_ts_test.bzl ├── wd_ts_type_test.bzl ├── wpt_get_directories.bzl └── wpt_test.bzl ├── compile_flags.txt ├── deps └── rust │ ├── BUILD.bazel │ ├── BUILD.lolhtml │ ├── Cargo.lock │ ├── cargo.bzl │ └── crates │ ├── BUILD.addr2line-0.24.2.bazel │ ├── BUILD.adler2-2.0.0.bazel │ ├── BUILD.aho-corasick-1.1.3.bazel │ ├── BUILD.allocator-api2-0.2.21.bazel │ ├── BUILD.anstyle-1.0.10.bazel │ ├── BUILD.anyhow-1.0.98.bazel │ ├── BUILD.backtrace-0.3.75.bazel │ ├── BUILD.bazel │ ├── BUILD.bitflags-2.9.1.bazel │ ├── BUILD.bstr-1.12.0.bazel │ ├── BUILD.byteorder-1.5.0.bazel │ ├── BUILD.capnp-0.21.0.bazel │ ├── BUILD.capnpc-0.21.0.bazel │ ├── BUILD.castaway-0.2.3.bazel │ ├── BUILD.cc-1.2.23.bazel │ ├── BUILD.cfg-if-1.0.0.bazel │ ├── BUILD.cfg_aliases-0.2.1.bazel │ ├── BUILD.clang-ast-0.1.31.bazel │ ├── BUILD.clap-4.5.38.bazel │ ├── BUILD.clap_builder-4.5.38.bazel │ ├── BUILD.clap_derive-4.5.32.bazel │ ├── BUILD.clap_lex-0.7.4.bazel │ ├── BUILD.codespan-reporting-0.12.0.bazel │ ├── BUILD.compact_str-0.9.0.bazel │ ├── BUILD.crc32fast-1.4.2.bazel │ ├── BUILD.cssparser-0.35.0.bazel │ ├── BUILD.cssparser-macros-0.6.1.bazel │ ├── BUILD.derive_more-0.99.20.bazel │ ├── BUILD.dtoa-1.0.10.bazel │ ├── BUILD.dtoa-short-0.3.5.bazel │ ├── BUILD.either-1.15.0.bazel │ ├── BUILD.embedded-io-0.6.1.bazel │ ├── BUILD.encoding_rs-0.8.35.bazel │ ├── BUILD.equivalent-1.0.2.bazel │ ├── BUILD.flate2-1.1.1.bazel │ ├── BUILD.foldhash-0.1.5.bazel │ ├── BUILD.fxhash-0.2.1.bazel │ ├── BUILD.getopts-0.2.21.bazel │ ├── BUILD.getrandom-0.2.16.bazel │ ├── BUILD.gimli-0.31.1.bazel │ ├── BUILD.hashbrown-0.15.3.bazel │ ├── BUILD.heck-0.5.0.bazel │ ├── BUILD.is-macro-0.3.7.bazel │ ├── BUILD.itertools-0.14.0.bazel │ ├── BUILD.itoa-1.0.15.bazel │ ├── BUILD.libc-0.2.172.bazel │ ├── BUILD.log-0.4.27.bazel │ ├── BUILD.lol_html-2.3.0.bazel │ ├── BUILD.lol_html_c_api-1.3.0.bazel │ ├── BUILD.memchr-2.7.4.bazel │ ├── BUILD.mime-0.3.17.bazel │ ├── BUILD.miniz_oxide-0.8.8.bazel │ ├── BUILD.mio-1.0.3.bazel │ ├── BUILD.new_debug_unreachable-1.0.6.bazel │ ├── BUILD.nix-0.30.1.bazel │ ├── BUILD.object-0.36.7.bazel │ ├── BUILD.once_cell-1.21.3.bazel │ ├── BUILD.phf-0.11.3.bazel │ ├── BUILD.phf_codegen-0.11.3.bazel │ ├── BUILD.phf_generator-0.11.3.bazel │ ├── BUILD.phf_macros-0.11.3.bazel │ ├── BUILD.phf_shared-0.11.3.bazel │ ├── BUILD.pico-args-0.5.0.bazel │ ├── BUILD.pin-project-lite-0.2.16.bazel │ ├── BUILD.ppv-lite86-0.2.21.bazel │ ├── BUILD.precomputed-hash-0.1.1.bazel │ ├── BUILD.proc-macro2-1.0.95.bazel │ ├── BUILD.quote-1.0.40.bazel │ ├── BUILD.rand-0.8.5.bazel │ ├── BUILD.rand_chacha-0.3.1.bazel │ ├── BUILD.rand_core-0.6.4.bazel │ ├── BUILD.regex-automata-0.4.9.bazel │ ├── BUILD.ruff_python_ast-0.0.0.bazel │ ├── BUILD.ruff_python_parser-0.0.0.bazel │ ├── BUILD.ruff_python_trivia-0.0.0.bazel │ ├── BUILD.ruff_source_file-0.0.0.bazel │ ├── BUILD.ruff_text_size-0.0.0.bazel │ ├── BUILD.rustc-demangle-0.1.24.bazel │ ├── BUILD.rustc-hash-2.1.1.bazel │ ├── BUILD.rustversion-1.0.20.bazel │ ├── BUILD.ryu-1.0.20.bazel │ ├── BUILD.scratch-1.0.8.bazel │ ├── BUILD.selectors-0.27.0.bazel │ ├── BUILD.serde-1.0.219.bazel │ ├── BUILD.serde_derive-1.0.219.bazel │ ├── BUILD.serde_json-1.0.140.bazel │ ├── BUILD.servo_arc-0.4.0.bazel │ ├── BUILD.shlex-1.3.0.bazel │ ├── BUILD.siphasher-1.0.1.bazel │ ├── BUILD.smallvec-1.15.0.bazel │ ├── BUILD.socket2-0.5.9.bazel │ ├── BUILD.stable_deref_trait-1.2.0.bazel │ ├── BUILD.static_assertions-1.1.0.bazel │ ├── BUILD.syn-2.0.101.bazel │ ├── BUILD.termcolor-1.4.1.bazel │ ├── BUILD.thiserror-2.0.12.bazel │ ├── BUILD.thiserror-impl-2.0.12.bazel │ ├── BUILD.tinyvec-1.9.0.bazel │ ├── BUILD.tinyvec_macros-0.1.1.bazel │ ├── BUILD.tokio-1.45.0.bazel │ ├── BUILD.tracing-0.1.41.bazel │ ├── BUILD.tracing-core-0.1.33.bazel │ ├── BUILD.unicode-ident-1.0.18.bazel │ ├── BUILD.unicode-normalization-0.1.24.bazel │ ├── BUILD.unicode-width-0.1.14.bazel │ ├── BUILD.unicode-width-0.2.0.bazel │ ├── BUILD.unicode_names2-1.3.0.bazel │ ├── BUILD.unicode_names2_generator-1.3.0.bazel │ ├── BUILD.wasi-0.11.0+wasi-snapshot-preview1.bazel │ ├── BUILD.winapi-util-0.1.9.bazel │ ├── BUILD.windows-sys-0.52.0.bazel │ ├── BUILD.windows-sys-0.59.0.bazel │ ├── BUILD.windows-targets-0.52.6.bazel │ ├── BUILD.windows_aarch64_gnullvm-0.52.6.bazel │ ├── BUILD.windows_aarch64_msvc-0.52.6.bazel │ ├── BUILD.windows_i686_gnu-0.52.6.bazel │ ├── BUILD.windows_i686_gnullvm-0.52.6.bazel │ ├── BUILD.windows_i686_msvc-0.52.6.bazel │ ├── BUILD.windows_x86_64_gnu-0.52.6.bazel │ ├── BUILD.windows_x86_64_gnullvm-0.52.6.bazel │ ├── BUILD.windows_x86_64_msvc-0.52.6.bazel │ ├── BUILD.zerocopy-0.8.25.bazel │ ├── BUILD.zerocopy-derive-0.8.25.bazel │ ├── alias_rules.bzl │ ├── crates.bzl │ └── defs.bzl ├── docs ├── api-updates.md ├── assets │ ├── banner.png │ ├── vscode-dev-container-modal.png │ └── vscode-dev-container-progress.png ├── benchmarking.md ├── development.md ├── pyodide.md ├── v8-updates.md └── vscode.md ├── doxyfile ├── empty └── empty ├── githooks ├── README ├── pre-commit └── pre-push ├── icudata-embed.capnp ├── justfile ├── npm ├── lib │ ├── node-install.ts │ ├── node-path.ts │ ├── node-platform.ts │ └── node-shim.ts ├── scripts │ ├── build-shim-package.mjs │ ├── build-types-package.mjs │ └── bump-version.mjs ├── workerd-darwin-64 │ ├── README.md │ └── package.json ├── workerd-darwin-arm64 │ ├── README.md │ └── package.json ├── workerd-linux-64 │ ├── README.md │ └── package.json ├── workerd-linux-arm64 │ ├── README.md │ └── package.json ├── workerd-windows-64 │ ├── README.md │ └── package.json ├── workerd │ ├── .gitignore │ ├── README.md │ └── package.json └── workers-types │ ├── README.md │ ├── entrypoints.svg │ └── package.json ├── package.json ├── patches ├── capnp-es.patch ├── sqlite │ ├── 0001-row-counts-plain.patch │ ├── 0002-macOS-missing-PATH-fix.patch │ ├── 0003-sqlite-complete-early-exit.patch │ └── README.md └── v8 │ ├── 0001-Allow-manually-setting-ValueDeserializer-format-vers.patch │ ├── 0002-Allow-manually-setting-ValueSerializer-format-versio.patch │ ├── 0003-Allow-Windows-builds-under-Bazel.patch │ ├── 0004-Disable-bazel-whole-archive-build.patch │ ├── 0005-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch │ ├── 0006-Implement-Promise-Context-Tagging.patch │ ├── 0007-Randomize-the-initial-ExecutionContextId-used-by-the.patch │ ├── 0008-increase-visibility-of-virtual-method.patch │ ├── 0009-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch │ ├── 0010-Modify-where-to-look-for-fp16-dependency.-This-depen.patch │ ├── 0011-Revert-TracedReference-deref-API-removal.patch │ ├── 0012-Revert-heap-Add-masm-specific-unwinding-annotations-.patch │ ├── 0013-Update-illegal-invocation-error-message-in-v8.patch │ ├── 0014-Implement-cross-request-context-promise-resolve-hand.patch │ ├── 0015-Add-another-slot-in-the-isolate-for-embedder.patch │ ├── 0016-Add-ValueSerializer-SetTreatProxiesAsHostObjects.patch │ ├── 0017-Disable-memory-leak-assert-when-shutting-down-V8.patch │ ├── 0018-Enable-V8-shared-linkage.patch │ ├── 0019-Modify-where-to-look-for-fast_float-and-simdutf.patch │ ├── 0020-Remove-unneded-latomic-linker-flag.patch │ ├── 0021-Add-methods-to-get-heap-and-external-memory-sizes-di.patch │ ├── 0022-Remove-DCHECK-from-WriteOneByteV2-to-skip-v8-fatal.patch │ └── 0023-Add-more-sandbox-APIs.patch ├── pnpm-lock.yaml ├── samples ├── BUILD.bazel ├── async-context │ ├── config.capnp │ └── worker.js ├── durable-objects-chat │ ├── chat.html │ ├── chat.js │ └── config.capnp ├── eventsource │ ├── README.md │ ├── config.capnp │ ├── server.js │ └── worker.js ├── extensions │ ├── README.md │ ├── binding.js │ ├── burrito-shop-impl.js │ ├── burrito-shop.capnp │ ├── burrito-shop.js │ ├── config.capnp │ ├── kitchen.js │ ├── recipes.json │ └── worker.js ├── hello-wasm │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ ├── config.capnp │ └── src │ │ ├── lib.rs │ │ └── utils.rs ├── helloworld │ ├── README.md │ ├── config.capnp │ └── worker.js ├── helloworld_esm │ ├── README.md │ ├── config.capnp │ └── worker.js ├── memory-cache │ ├── README.md │ ├── config.capnp │ └── worker.js ├── module_fallback │ ├── README.md │ ├── cjs.js │ ├── config.capnp │ ├── fallback.js │ └── worker.js ├── nodejs-compat-crypto │ ├── README.md │ ├── config.capnp │ └── worker.js ├── nodejs-compat-diagnosticschannel │ ├── README.md │ ├── config.capnp │ ├── library.js │ └── worker.js ├── nodejs-compat-streams-split2 │ ├── README.md │ ├── config.capnp │ ├── split2.js │ └── worker.js ├── nodejs-compat-streams │ ├── README.md │ ├── config.capnp │ └── worker.js ├── nodejs-compat │ ├── README.md │ ├── config.capnp │ └── worker.js ├── pyodide-fastapi │ ├── config.capnp │ └── worker.py ├── pyodide-langchain │ ├── config.capnp │ └── worker.py ├── pyodide-secret │ ├── config.capnp │ └── worker.py ├── pyodide │ ├── config.capnp │ └── worker.py ├── repl-server-python │ ├── README.md │ ├── client.js │ ├── config.capnp │ └── worker.py ├── repl-server │ ├── README.md │ ├── client.js │ ├── config.capnp │ └── worker.js ├── static-files-from-disk │ ├── config.capnp │ ├── content-dir │ │ └── index.html │ └── static.js ├── tail-workers │ ├── config.capnp │ ├── tail.js │ └── worker.js ├── tcp │ ├── config.capnp │ └── gopher.js ├── unit-tests │ ├── config.capnp │ └── worker.js └── webfs │ ├── README.md │ ├── config.capnp │ └── worker.js ├── src ├── cloudflare │ ├── BUILD.bazel │ ├── README.md │ ├── ai.ts │ ├── br.ts │ ├── email.ts │ ├── eslint.config.mjs │ ├── internal │ │ ├── ai-api.ts │ │ ├── aig-api.ts │ │ ├── autorag-api.ts │ │ ├── br-api.ts │ │ ├── compatibility-flags.d.ts │ │ ├── d1-api.ts │ │ ├── email.d.ts │ │ ├── env.d.ts │ │ ├── images-api.ts │ │ ├── images.d.ts │ │ ├── pipeline-transform.ts │ │ ├── sockets.d.ts │ │ ├── test │ │ │ ├── ai │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── ai-api-test.js │ │ │ │ ├── ai-api-test.py │ │ │ │ ├── ai-api-test.wd-test │ │ │ │ ├── ai-mock.js │ │ │ │ └── python-ai-api-test.wd-test │ │ │ ├── aig │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── aig-api-test.js │ │ │ │ ├── aig-api-test.py │ │ │ │ ├── aig-api-test.wd-test │ │ │ │ ├── aig-mock.js │ │ │ │ └── python-aig-api-test.wd-test │ │ │ ├── autorag │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── autorag-api-test.js │ │ │ │ ├── autorag-api-test.py │ │ │ │ ├── autorag-api-test.wd-test │ │ │ │ ├── autorag-mock.js │ │ │ │ └── python-autorag-api-test.wd-test │ │ │ ├── br │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── br-api-test.js │ │ │ │ ├── br-api-test.py │ │ │ │ ├── br-api-test.wd-test │ │ │ │ ├── br-mock.js │ │ │ │ └── python-br-api-test.wd-test │ │ │ ├── d1 │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── d1-api-test-common.js │ │ │ │ ├── d1-api-test-with-sessions.js │ │ │ │ ├── d1-api-test-with-sessions.wd-test │ │ │ │ ├── d1-api-test.js │ │ │ │ ├── d1-api-test.py │ │ │ │ ├── d1-api-test.wd-test │ │ │ │ ├── d1-mock.js │ │ │ │ └── python-d1-api-test.wd-test │ │ │ ├── images │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── images-api-test.js │ │ │ │ ├── images-api-test.wd-test │ │ │ │ └── images-upstream-mock.js │ │ │ ├── pipeline-transform │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── transform-test.js │ │ │ │ └── transform.wd-test │ │ │ ├── vectorize │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── python-vectorize-api-test.wd-test │ │ │ │ ├── vectorize-api-test.js │ │ │ │ ├── vectorize-api-test.py │ │ │ │ ├── vectorize-api-test.wd-test │ │ │ │ └── vectorize-mock.js │ │ │ └── workflows │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── workflows-api-test.js │ │ │ │ ├── workflows-api-test.wd-test │ │ │ │ └── workflows-mock.js │ │ ├── vectorize-api.ts │ │ ├── vectorize.d.ts │ │ ├── workers.d.ts │ │ ├── workflows-api.ts │ │ └── workflows.d.ts │ ├── pipelines.ts │ ├── sockets.ts │ ├── tsconfig.json │ ├── vectorize.ts │ ├── workers.ts │ └── workflows.ts ├── node │ ├── BUILD.bazel │ ├── README.md │ ├── _http_common.ts │ ├── _http_outgoing.ts │ ├── _stream_duplex.js │ ├── _stream_passthrough.js │ ├── _stream_readable.js │ ├── _stream_transform.js │ ├── _stream_writable.js │ ├── _tls_common.ts │ ├── _tls_wrap.ts │ ├── assert.ts │ ├── assert │ │ └── strict.ts │ ├── async_hooks.ts │ ├── buffer.ts │ ├── crypto.ts │ ├── diagnostics_channel.ts │ ├── dns.ts │ ├── dns │ │ └── promises.ts │ ├── eslint.config.mjs │ ├── events.ts │ ├── fs.ts │ ├── fs │ │ └── promises.ts │ ├── http.ts │ ├── internal │ │ ├── async_hooks.d.ts │ │ ├── buffer.d.ts │ │ ├── compatibility-flags.d.ts │ │ ├── constants.ts │ │ ├── crypto.d.ts │ │ ├── crypto_cipher.ts │ │ ├── crypto_dh.ts │ │ ├── crypto_hash.ts │ │ ├── crypto_hkdf.ts │ │ ├── crypto_keys.ts │ │ ├── crypto_pbkdf2.ts │ │ ├── crypto_random.ts │ │ ├── crypto_scrypt.ts │ │ ├── crypto_sign.ts │ │ ├── crypto_spkac.ts │ │ ├── crypto_util.ts │ │ ├── crypto_x509.ts │ │ ├── debuglog.ts │ │ ├── diagnostics_channel.d.ts │ │ ├── dns.d.ts │ │ ├── events.ts │ │ ├── filesystem.d.ts │ │ ├── internal_assert.ts │ │ ├── internal_assertionerror.ts │ │ ├── internal_buffer.ts │ │ ├── internal_comparisons.ts │ │ ├── internal_diffs.ts │ │ ├── internal_dns.ts │ │ ├── internal_dns_client.ts │ │ ├── internal_dns_constants.ts │ │ ├── internal_dns_promises.ts │ │ ├── internal_errors.ts │ │ ├── internal_fs.ts │ │ ├── internal_fs_callback.ts │ │ ├── internal_fs_constants.ts │ │ ├── internal_fs_promises.ts │ │ ├── internal_fs_streams.ts │ │ ├── internal_fs_sync.ts │ │ ├── internal_fs_utils.ts │ │ ├── internal_http.ts │ │ ├── internal_http_constants.ts │ │ ├── internal_inspect.ts │ │ ├── internal_net.ts │ │ ├── internal_path.ts │ │ ├── internal_querystring.ts │ │ ├── internal_stringdecoder.ts │ │ ├── internal_timers.ts │ │ ├── internal_timers_promises.ts │ │ ├── internal_tls.ts │ │ ├── internal_tls_common.ts │ │ ├── internal_tls_constants.ts │ │ ├── internal_tls_jsstream.ts │ │ ├── internal_tls_wrap.ts │ │ ├── internal_types.ts │ │ ├── internal_url.ts │ │ ├── internal_utils.ts │ │ ├── internal_zlib.ts │ │ ├── internal_zlib_base.ts │ │ ├── internal_zlib_constants.ts │ │ ├── legacy_url.ts │ │ ├── mock.js │ │ ├── module.d.ts │ │ ├── process.ts │ │ ├── sockets.d.ts │ │ ├── streams_adapters.js │ │ ├── streams_compose.js │ │ ├── streams_duplex.d.ts │ │ ├── streams_duplex.js │ │ ├── streams_legacy.js │ │ ├── streams_pipeline.js │ │ ├── streams_promises.js │ │ ├── streams_readable.d.ts │ │ ├── streams_readable.js │ │ ├── streams_transform.d.ts │ │ ├── streams_transform.js │ │ ├── streams_util.d.ts │ │ ├── streams_util.js │ │ ├── streams_writable.d.ts │ │ ├── streams_writable.js │ │ ├── timers.d.ts │ │ ├── url.d.ts │ │ ├── util.d.ts │ │ ├── validators.ts │ │ ├── workers.d.ts │ │ └── zlib.d.ts │ ├── module.ts │ ├── net.ts │ ├── path.ts │ ├── path │ │ ├── posix.ts │ │ └── win32.ts │ ├── process.ts │ ├── querystring.ts │ ├── stream.js │ ├── stream │ │ ├── consumers.js │ │ ├── promises.js │ │ └── web.js │ ├── string_decoder.ts │ ├── test.js │ ├── timers.ts │ ├── timers │ │ └── promises.ts │ ├── tls.ts │ ├── tsconfig.json │ ├── url.ts │ ├── util.ts │ ├── util │ │ └── types.ts │ └── zlib.ts ├── pyodide │ ├── BUILD.bazel │ ├── README.md │ ├── eslint.config.mjs │ ├── helpers.bzl │ ├── internal │ │ ├── asgi.py │ │ ├── introspection.py │ │ ├── jaeger.ts │ │ ├── loadPackage.ts │ │ ├── metadata.ts │ │ ├── metadatafs.ts │ │ ├── patches │ │ │ ├── aiohttp.py │ │ │ └── httpx.py │ │ ├── pool │ │ │ ├── builtin_wrappers.ts │ │ │ ├── emscriptenSetup.ts │ │ │ └── esbuild.config.mjs │ │ ├── python.ts │ │ ├── readOnlyFS.ts │ │ ├── setupPackages.ts │ │ ├── snapshot.ts │ │ ├── sphinx │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── conf.py │ │ │ ├── docs │ │ │ │ ├── asgi.rst │ │ │ │ ├── modules.rst │ │ │ │ └── workers.rst │ │ │ ├── index.rst │ │ │ ├── make.bat │ │ │ └── requirements-doc.txt │ │ ├── tar.ts │ │ ├── tarfs.ts │ │ ├── topLevelEntropy │ │ │ ├── __init__.py │ │ │ ├── entropy_import_context.py │ │ │ ├── entropy_import_context.py.d.ts │ │ │ ├── entropy_patches.py │ │ │ ├── entropy_patches.py.d.ts │ │ │ ├── import_patch_manager.py │ │ │ ├── import_patch_manager.py.d.ts │ │ │ └── lib.ts │ │ ├── util.ts │ │ └── workers.py │ ├── pyodide_extra.capnp │ ├── python-entrypoint-helper.ts │ ├── python-entrypoint.js │ ├── tsconfig.json │ ├── types │ │ ├── Error.d.ts │ │ ├── Pyodide.d.ts │ │ ├── artifacts.d.ts │ │ ├── disk_cache.d.ts │ │ ├── emscripten.d.ts │ │ ├── filesystem.d.ts │ │ ├── internalJaeger.d.ts │ │ ├── limiter.d.ts │ │ ├── modules.d.ts │ │ ├── packages_tar_reader.d.ts │ │ ├── pyodide-lock.d.ts │ │ ├── pyodide.asm.d.ts │ │ ├── python_stdlib.zip.d.ts │ │ ├── runtime-generated │ │ │ └── metadata.d.ts │ │ ├── setup-emscripten.d.ts │ │ └── unsafe-eval.d.ts │ └── upload_bundles.py ├── rust │ ├── BUILD.bazel │ ├── cxx-integration-test │ │ ├── BUILD.bazel │ │ ├── cxx-rust-integration-test.c++ │ │ ├── cxx-rust-integration-test.h │ │ └── lib.rs │ ├── cxx-integration │ │ ├── BUILD.bazel │ │ ├── cxx-bridge.h │ │ ├── lib.rs │ │ └── tokio.rs │ ├── dns │ │ ├── BUILD.bazel │ │ └── lib.rs │ ├── gen-compile-cache │ │ ├── BUILD.bazel │ │ ├── cxx-bridge.c++ │ │ ├── cxx-bridge.h │ │ └── main.rs │ ├── net │ │ ├── BUILD.bazel │ │ └── lib.rs │ ├── python-parser │ │ ├── BUILD │ │ ├── import_parsing.c++ │ │ └── lib.rs │ └── rustfmt.toml ├── workerd │ ├── README.md │ ├── api │ │ ├── BUILD.bazel │ │ ├── actor-alarms-delete-test.js │ │ ├── actor-alarms-delete-test.wd-test │ │ ├── actor-alarms-test.js │ │ ├── actor-alarms-test.wd-test │ │ ├── actor-state-iocontext-test.c++ │ │ ├── actor-state-test.c++ │ │ ├── actor-state.c++ │ │ ├── actor-state.h │ │ ├── actor.c++ │ │ ├── actor.h │ │ ├── analytics-engine-impl.h │ │ ├── analytics-engine-test.js │ │ ├── analytics-engine-test.wd-test │ │ ├── analytics-engine.c++ │ │ ├── analytics-engine.capnp │ │ ├── analytics-engine.h │ │ ├── api-rtti-test.c++ │ │ ├── basics-test.c++ │ │ ├── basics.c++ │ │ ├── basics.h │ │ ├── blob.c++ │ │ ├── blob.h │ │ ├── cache.c++ │ │ ├── cache.h │ │ ├── cf-property-test.c++ │ │ ├── cf-property.c++ │ │ ├── cf-property.h │ │ ├── commonjs.c++ │ │ ├── commonjs.h │ │ ├── container.c++ │ │ ├── container.h │ │ ├── crypto │ │ │ ├── aes-test.c++ │ │ │ ├── aes.c++ │ │ │ ├── crc-impl.c++ │ │ │ ├── crc-impl.h │ │ │ ├── crypto.c++ │ │ │ ├── crypto.h │ │ │ ├── dh-primes.h │ │ │ ├── dh.c++ │ │ │ ├── dh.h │ │ │ ├── digest.c++ │ │ │ ├── digest.h │ │ │ ├── ec.c++ │ │ │ ├── ec.h │ │ │ ├── endianness.c++ │ │ │ ├── endianness.h │ │ │ ├── hkdf.c++ │ │ │ ├── impl-test.c++ │ │ │ ├── impl.c++ │ │ │ ├── impl.h │ │ │ ├── jwk.c++ │ │ │ ├── jwk.h │ │ │ ├── kdf.h │ │ │ ├── keys.c++ │ │ │ ├── keys.h │ │ │ ├── pbkdf2.c++ │ │ │ ├── prime.c++ │ │ │ ├── prime.h │ │ │ ├── rsa.c++ │ │ │ ├── rsa.h │ │ │ ├── scrypt.c++ │ │ │ ├── spkac.c++ │ │ │ ├── spkac.h │ │ │ ├── x509.c++ │ │ │ └── x509.h │ │ ├── ctx-props-test.wd-test │ │ ├── data-url-test.c++ │ │ ├── data-url.c++ │ │ ├── data-url.h │ │ ├── deferred-proxy-test.c++ │ │ ├── deferred-proxy.h │ │ ├── encoding.c++ │ │ ├── encoding.h │ │ ├── events.c++ │ │ ├── events.h │ │ ├── eventsource.c++ │ │ ├── eventsource.h │ │ ├── filesystem.c++ │ │ ├── filesystem.h │ │ ├── form-data-memory-test.c++ │ │ ├── form-data.c++ │ │ ├── form-data.h │ │ ├── global-scope.c++ │ │ ├── global-scope.h │ │ ├── headers-test.c++ │ │ ├── hibernatable-web-socket.c++ │ │ ├── hibernatable-web-socket.h │ │ ├── hibernation-event-params.h │ │ ├── html-rewriter.c++ │ │ ├── html-rewriter.h │ │ ├── http-standard-test.js │ │ ├── http-standard-test.wd-test │ │ ├── http-test-ts.ts │ │ ├── http-test-ts.ts-wd-test │ │ ├── http-test.js │ │ ├── http-test.wd-test │ │ ├── http.c++ │ │ ├── http.h │ │ ├── hyperdrive.c++ │ │ ├── hyperdrive.h │ │ ├── kv-test.js │ │ ├── kv-test.wd-test │ │ ├── kv.c++ │ │ ├── kv.h │ │ ├── memory-cache.c++ │ │ ├── memory-cache.h │ │ ├── modules.c++ │ │ ├── modules.h │ │ ├── node │ │ │ ├── BUILD.bazel │ │ │ ├── async-hooks.c++ │ │ │ ├── async-hooks.h │ │ │ ├── buffer-string-search.h │ │ │ ├── buffer-test.c++ │ │ │ ├── buffer.c++ │ │ │ ├── buffer.h │ │ │ ├── crypto-keys.c++ │ │ │ ├── crypto.c++ │ │ │ ├── crypto.h │ │ │ ├── diagnostics-channel.c++ │ │ │ ├── diagnostics-channel.h │ │ │ ├── dns.c++ │ │ │ ├── dns.h │ │ │ ├── i18n.c++ │ │ │ ├── i18n.h │ │ │ ├── module.c++ │ │ │ ├── module.h │ │ │ ├── node.h │ │ │ ├── tests │ │ │ │ ├── assert-test.js │ │ │ │ ├── assert-test.wd-test │ │ │ │ ├── async_hooks-nodejs-test.js │ │ │ │ ├── async_hooks-nodejs-test.wd-test │ │ │ │ ├── bound-als-test.js │ │ │ │ ├── bound-als-test.wd-test │ │ │ │ ├── buffer-nodejs-test.js │ │ │ │ ├── buffer-nodejs-test.wd-test │ │ │ │ ├── crypto_cipher-test.js │ │ │ │ ├── crypto_cipher-test.wd-test │ │ │ │ ├── crypto_dh-test.js │ │ │ │ ├── crypto_dh-test.wd-test │ │ │ │ ├── crypto_hash-test.js │ │ │ │ ├── crypto_hash-test.wd-test │ │ │ │ ├── crypto_hkdf-test.js │ │ │ │ ├── crypto_hkdf-test.wd-test │ │ │ │ ├── crypto_hmac-test.js │ │ │ │ ├── crypto_hmac-test.wd-test │ │ │ │ ├── crypto_keys-test.js │ │ │ │ ├── crypto_keys-test.wd-test │ │ │ │ ├── crypto_pbkdf2-test.js │ │ │ │ ├── crypto_pbkdf2-test.wd-test │ │ │ │ ├── crypto_random-test.js │ │ │ │ ├── crypto_random-test.wd-test │ │ │ │ ├── crypto_scrypt-test.js │ │ │ │ ├── crypto_scrypt-test.wd-test │ │ │ │ ├── crypto_sign-test.js │ │ │ │ ├── crypto_sign-test.wd-test │ │ │ │ ├── crypto_spkac-test.js │ │ │ │ ├── crypto_spkac-test.wd-test │ │ │ │ ├── crypto_x509-test.js │ │ │ │ ├── crypto_x509-test.wd-test │ │ │ │ ├── diagnostics-channel-test.js │ │ │ │ ├── diagnostics-channel-test.wd-test │ │ │ │ ├── dns-nodejs-test.js │ │ │ │ ├── dns-nodejs-test.wd-test │ │ │ │ ├── fixtures │ │ │ │ │ ├── agent1-cert.pem │ │ │ │ │ ├── dh_private.pem │ │ │ │ │ ├── dh_public.pem │ │ │ │ │ ├── dsa_private.pem │ │ │ │ │ ├── dsa_private_1025.pem │ │ │ │ │ ├── dsa_private_encrypted.pem │ │ │ │ │ ├── dsa_private_encrypted_1025.pem │ │ │ │ │ ├── dsa_private_pkcs8.pem │ │ │ │ │ ├── dsa_public.pem │ │ │ │ │ ├── dsa_public_1025.pem │ │ │ │ │ ├── ec_p256_private.pem │ │ │ │ │ ├── ec_p256_public.pem │ │ │ │ │ ├── ec_p384_private.pem │ │ │ │ │ ├── ec_p384_public.pem │ │ │ │ │ ├── ec_p521_private.pem │ │ │ │ │ ├── ec_p521_public.pem │ │ │ │ │ ├── ec_secp256k1_private.pem │ │ │ │ │ ├── ec_secp256k1_public.pem │ │ │ │ │ ├── ed25519_private.pem │ │ │ │ │ ├── ed25519_public.pem │ │ │ │ │ ├── ed448_private.pem │ │ │ │ │ ├── ed448_public.pem │ │ │ │ │ ├── rsa_private.pem │ │ │ │ │ ├── rsa_private_2048.pem │ │ │ │ │ ├── rsa_private_4096.pem │ │ │ │ │ ├── rsa_private_b.pem │ │ │ │ │ ├── rsa_private_encrypted.pem │ │ │ │ │ ├── rsa_private_pkcs8.pem │ │ │ │ │ ├── rsa_private_pkcs8_bad.pem │ │ │ │ │ ├── rsa_pss_private_2048.pem │ │ │ │ │ ├── rsa_pss_private_2048_sha1_sha1_20.pem │ │ │ │ │ ├── rsa_pss_private_2048_sha256_sha256_16.pem │ │ │ │ │ ├── rsa_pss_private_2048_sha512_sha256_20.pem │ │ │ │ │ ├── rsa_pss_public_2048.pem │ │ │ │ │ ├── rsa_pss_public_2048_sha1_sha1_20.pem │ │ │ │ │ ├── rsa_pss_public_2048_sha256_sha256_16.pem │ │ │ │ │ ├── rsa_pss_public_2048_sha512_sha256_20.pem │ │ │ │ │ ├── rsa_public.pem │ │ │ │ │ ├── rsa_public_2048.pem │ │ │ │ │ ├── rsa_public_4096.pem │ │ │ │ │ ├── rsa_public_b.pem │ │ │ │ │ ├── tls-nodejs-tcp-server.pem │ │ │ │ │ ├── x25519_private.pem │ │ │ │ │ ├── x25519_public.pem │ │ │ │ │ ├── x448_private.pem │ │ │ │ │ └── x448_public.pem │ │ │ │ ├── fs-access-test.js │ │ │ │ ├── fs-access-test.wd-test │ │ │ │ ├── http-nodejs-test.js │ │ │ │ ├── http-nodejs-test.wd-test │ │ │ │ ├── legacy_url-nodejs-test.js │ │ │ │ ├── legacy_url-nodejs-test.wd-test │ │ │ │ ├── mimetype-test.js │ │ │ │ ├── mimetype-test.wd-test │ │ │ │ ├── module-create-require-test.js │ │ │ │ ├── module-create-require-test.wd-test │ │ │ │ ├── net-nodejs-tcp-server.js │ │ │ │ ├── net-nodejs-test.js │ │ │ │ ├── net-nodejs-test.wd-test │ │ │ │ ├── node-compat-v2-test.js │ │ │ │ ├── node-compat-v2-test.wd-test │ │ │ │ ├── path-test.js │ │ │ │ ├── path-test.wd-test │ │ │ │ ├── process-exit-test.js │ │ │ │ ├── process-exit-test.wd-test │ │ │ │ ├── process-nodejs-test.js │ │ │ │ ├── process-nodejs-test.wd-test │ │ │ │ ├── querystring-nodejs-test.js │ │ │ │ ├── querystring-nodejs-test.wd-test │ │ │ │ ├── sidecar-supervisor.mjs │ │ │ │ ├── streams-nodejs-test.js │ │ │ │ ├── streams-nodejs-test.wd-test │ │ │ │ ├── streams-test.js │ │ │ │ ├── streams-test.wd-test │ │ │ │ ├── string-decoder-test.js │ │ │ │ ├── string-decoder-test.wd-test │ │ │ │ ├── sys-nodejs-test.js │ │ │ │ ├── sys-nodejs-test.wd-test │ │ │ │ ├── timers-nodejs-test.js │ │ │ │ ├── timers-nodejs-test.wd-test │ │ │ │ ├── tls-nodejs-tcp-server.js │ │ │ │ ├── tls-nodejs-test.js │ │ │ │ ├── tls-nodejs-test.wd-test │ │ │ │ ├── url-nodejs-test.js │ │ │ │ ├── url-nodejs-test.wd-test │ │ │ │ ├── util-nodejs-test.js │ │ │ │ ├── util-nodejs-test.wd-test │ │ │ │ ├── zlib-nodejs-test.js │ │ │ │ └── zlib-nodejs-test.wd-test │ │ │ ├── timers.c++ │ │ │ ├── timers.h │ │ │ ├── url.c++ │ │ │ ├── url.h │ │ │ ├── util.c++ │ │ │ ├── util.h │ │ │ ├── zlib-util.c++ │ │ │ └── zlib-util.h │ │ ├── pyodide │ │ │ ├── pyodide-test.c++ │ │ │ ├── pyodide.c++ │ │ │ ├── pyodide.h │ │ │ ├── requirements.c++ │ │ │ ├── requirements.h │ │ │ ├── setup-emscripten.c++ │ │ │ └── setup-emscripten.h │ │ ├── queue-test.js │ │ ├── queue-test.wd-test │ │ ├── queue.c++ │ │ ├── queue.h │ │ ├── r2-admin.c++ │ │ ├── r2-admin.h │ │ ├── r2-api.capnp │ │ ├── r2-bucket.c++ │ │ ├── r2-bucket.h │ │ ├── r2-multipart.c++ │ │ ├── r2-multipart.h │ │ ├── r2-rpc.c++ │ │ ├── r2-rpc.h │ │ ├── r2-test.js │ │ ├── r2-test.wd-test │ │ ├── r2.h │ │ ├── rtti-test.js │ │ ├── rtti-test.wd-test │ │ ├── rtti.c++ │ │ ├── rtti.h │ │ ├── scheduled.c++ │ │ ├── scheduled.h │ │ ├── self-logger-test.js │ │ ├── self-logger-test.wd-test │ │ ├── sockets.c++ │ │ ├── sockets.h │ │ ├── sql-test.js │ │ ├── sql-test.wd-test │ │ ├── sql.c++ │ │ ├── sql.h │ │ ├── streams.h │ │ ├── streams │ │ │ ├── README.md │ │ │ ├── common.c++ │ │ │ ├── common.h │ │ │ ├── compression.c++ │ │ │ ├── compression.h │ │ │ ├── encoding.c++ │ │ │ ├── encoding.h │ │ │ ├── identitytransformstream-backpressure-test.js │ │ │ ├── identitytransformstream-backpressure-test.wd-test │ │ │ ├── internal-test.c++ │ │ │ ├── internal.c++ │ │ │ ├── internal.h │ │ │ ├── queue-test.c++ │ │ │ ├── queue.c++ │ │ │ ├── queue.h │ │ │ ├── readable.c++ │ │ │ ├── readable.h │ │ │ ├── standard-test.c++ │ │ │ ├── standard.c++ │ │ │ ├── standard.h │ │ │ ├── streams-test.js │ │ │ ├── streams-test.wd-test │ │ │ ├── transform.c++ │ │ │ ├── transform.h │ │ │ ├── writable.c++ │ │ │ └── writable.h │ │ ├── system-streams.c++ │ │ ├── system-streams.h │ │ ├── tail-worker-test-dummy.js │ │ ├── tail-worker-test-invalid.js │ │ ├── tail-worker-test-receiver.js │ │ ├── tail-worker-test.js │ │ ├── tail-worker-test.wd-test │ │ ├── tests │ │ │ ├── abort-internal-streams-test.js │ │ │ ├── abort-internal-streams-test.wd-test │ │ │ ├── abortable-fetch-test.js │ │ │ ├── abortable-fetch-test.wd-test │ │ │ ├── abortsignal-test.js │ │ │ ├── abortsignal-test.wd-test │ │ │ ├── actor-stub-test.js │ │ │ ├── actor-stub-test.wd-test │ │ │ ├── als-only-test.js │ │ │ ├── als-only-test.wd-test │ │ │ ├── als-test.js │ │ │ ├── als-test.wd-test │ │ │ ├── blob-test.js │ │ │ ├── blob-test.wd-test │ │ │ ├── blob2-test.js │ │ │ ├── blob2-test.wd-test │ │ │ ├── commonjs-module-test.js │ │ │ ├── commonjs-module-test.wd-test │ │ │ ├── compat-flags-test.js │ │ │ ├── compat-flags-test.wd-test │ │ │ ├── cross-context-promise-test.js │ │ │ ├── cross-context-promise-test.wd-test │ │ │ ├── crypto-extras-test.js │ │ │ ├── crypto-extras-test.wd-test │ │ │ ├── crypto-impl-asymmetric-test.js │ │ │ ├── crypto-impl-asymmetric-test.wd-test │ │ │ ├── crypto-streams-test.js │ │ │ ├── crypto-streams-test.wd-test │ │ │ ├── data-url-fetch-test.js │ │ │ ├── data-url-fetch-test.wd-test │ │ │ ├── disable-importable-env-test.js │ │ │ ├── disable-importable-env-test.wd-test │ │ │ ├── encoding-test.js │ │ │ ├── encoding-test.wd-test │ │ │ ├── error-in-error-event-test.js │ │ │ ├── error-in-error-event-test.wd-test │ │ │ ├── events-test.js │ │ │ ├── events-test.wd-test │ │ │ ├── eventsource-test.js │ │ │ ├── eventsource-test.wd-test │ │ │ ├── fetch-test.js │ │ │ ├── fetch-test.wd-test │ │ │ ├── form-data-legacy-test.js │ │ │ ├── form-data-legacy-test.wd-test │ │ │ ├── form-data-test.js │ │ │ ├── form-data-test.wd-test │ │ │ ├── global-scope-test.js │ │ │ ├── global-scope-test.wd-test │ │ │ ├── htmlrewriter-test.js │ │ │ ├── htmlrewriter-test.wd-test │ │ │ ├── importable-env-test.js │ │ │ ├── importable-env-test.wd-test │ │ │ ├── js-rpc-flag.js │ │ │ ├── js-rpc-flag.wd-test │ │ │ ├── js-rpc-socket-test.wd-test │ │ │ ├── js-rpc-test.js │ │ │ ├── js-rpc-test.wd-test │ │ │ ├── memory-cache-test.js │ │ │ ├── memory-cache-test.wd-test │ │ │ ├── module-test.js │ │ │ ├── module-test.wd-test │ │ │ ├── navigator-beacon-test.js │ │ │ ├── navigator-beacon-test.wd-test │ │ │ ├── navigator-test.js │ │ │ ├── navigator-test.wd-test │ │ │ ├── new-module-registry-test.js │ │ │ ├── new-module-registry-test.wd-test │ │ │ ├── no-to-string-tag-test.js │ │ │ ├── no-to-string-tag-test.wd-test │ │ │ ├── reporterror-test.js │ │ │ ├── reporterror-test.wd-test │ │ │ ├── request-signal-disabled.js │ │ │ ├── request-signal-disabled.wd-test │ │ │ ├── request-signal-enabled.js │ │ │ ├── request-signal-enabled.wd-test │ │ │ ├── request-signal-passthrough.js │ │ │ ├── request-signal-passthrough.wd-test │ │ │ ├── response-json.js │ │ │ ├── response-json.wd-test │ │ │ ├── scheduler-test.js │ │ │ ├── scheduler-test.wd-test │ │ │ ├── streams-test.js │ │ │ ├── streams-test.wd-test │ │ │ ├── test.wasm │ │ │ ├── unsafe-test.js │ │ │ ├── unsafe-test.wd-test │ │ │ ├── url-test.js │ │ │ ├── url-test.wd-test │ │ │ ├── webfs-test.js │ │ │ ├── webfs-test.wd-test │ │ │ ├── websocket-client-error-sidecar.js │ │ │ ├── websocket-client-error-test.js │ │ │ ├── websocket-client-error-test.wd-test │ │ │ ├── websocket-hibernation.js │ │ │ ├── websocket-hibernation.wd-test │ │ │ ├── worker-test.js │ │ │ └── worker-test.wd-test │ │ ├── trace.c++ │ │ ├── trace.h │ │ ├── tsconfig.json │ │ ├── unsafe.c++ │ │ ├── unsafe.h │ │ ├── url-standard.c++ │ │ ├── url-standard.h │ │ ├── url.c++ │ │ ├── url.h │ │ ├── urlpattern-standard.c++ │ │ ├── urlpattern-standard.h │ │ ├── urlpattern.c++ │ │ ├── urlpattern.h │ │ ├── util-test.c++ │ │ ├── util.c++ │ │ ├── util.h │ │ ├── web-socket.c++ │ │ ├── web-socket.h │ │ ├── worker-rpc.c++ │ │ └── worker-rpc.h │ ├── io │ │ ├── BUILD.bazel │ │ ├── actor-cache-test.c++ │ │ ├── actor-cache.c++ │ │ ├── actor-cache.h │ │ ├── actor-id.h │ │ ├── actor-sqlite-test.c++ │ │ ├── actor-sqlite.c++ │ │ ├── actor-sqlite.h │ │ ├── actor-storage.c++ │ │ ├── actor-storage.capnp │ │ ├── actor-storage.h │ │ ├── cdp.capnp │ │ ├── compatibility-date-test.c++ │ │ ├── compatibility-date.c++ │ │ ├── compatibility-date.capnp │ │ ├── compatibility-date.h │ │ ├── container.capnp │ │ ├── features.c++ │ │ ├── features.capnp │ │ ├── features.h │ │ ├── frankenvalue-test.c++ │ │ ├── frankenvalue.c++ │ │ ├── frankenvalue.capnp │ │ ├── frankenvalue.h │ │ ├── hibernation-manager.c++ │ │ ├── hibernation-manager.h │ │ ├── io-channels.h │ │ ├── io-context-test.js │ │ ├── io-context-test.wd-test │ │ ├── io-context.c++ │ │ ├── io-context.h │ │ ├── io-gate-test.c++ │ │ ├── io-gate.c++ │ │ ├── io-gate.h │ │ ├── io-own.c++ │ │ ├── io-own.h │ │ ├── io-thread-context.c++ │ │ ├── io-thread-context.h │ │ ├── io-timers.c++ │ │ ├── io-timers.h │ │ ├── io-util.c++ │ │ ├── io-util.h │ │ ├── limit-enforcer.h │ │ ├── observer-test.c++ │ │ ├── observer.c++ │ │ ├── observer.h │ │ ├── outcome.capnp │ │ ├── promise-wrapper-test.c++ │ │ ├── promise-wrapper.h │ │ ├── request-tracker.c++ │ │ ├── request-tracker.h │ │ ├── script-version.capnp │ │ ├── supported-compatibility-date.capnp │ │ ├── supported-compatibility-date.txt │ │ ├── trace-stream.c++ │ │ ├── trace-stream.h │ │ ├── trace-test.c++ │ │ ├── trace.c++ │ │ ├── trace.capnp │ │ ├── trace.h │ │ ├── tracer.c++ │ │ ├── tracer.h │ │ ├── worker-entrypoint.c++ │ │ ├── worker-entrypoint.h │ │ ├── worker-fs-test.c++ │ │ ├── worker-fs.c++ │ │ ├── worker-fs.h │ │ ├── worker-interface.c++ │ │ ├── worker-interface.capnp │ │ ├── worker-interface.h │ │ ├── worker.c++ │ │ └── worker.h │ ├── jsg │ │ ├── BUILD.bazel │ │ ├── README.md │ │ ├── async-context.c++ │ │ ├── async-context.h │ │ ├── buffersource-test.c++ │ │ ├── buffersource.c++ │ │ ├── buffersource.h │ │ ├── compile-cache.c++ │ │ ├── compile-cache.h │ │ ├── dom-exception-test.c++ │ │ ├── dom-exception.c++ │ │ ├── dom-exception.h │ │ ├── exception.c++ │ │ ├── exception.h │ │ ├── fast-api-test.c++ │ │ ├── fast-api.h │ │ ├── function-test.c++ │ │ ├── function.h │ │ ├── inspector.c++ │ │ ├── inspector.h │ │ ├── iterator-test.c++ │ │ ├── iterator.c++ │ │ ├── iterator.h │ │ ├── jsg-test.c++ │ │ ├── jsg-test.h │ │ ├── jsg.c++ │ │ ├── jsg.h │ │ ├── jsvalue-test.c++ │ │ ├── jsvalue.c++ │ │ ├── jsvalue.h │ │ ├── macro-meta-test.c++ │ │ ├── macro-meta.h │ │ ├── memory-test.c++ │ │ ├── memory.c++ │ │ ├── memory.h │ │ ├── meta.h │ │ ├── modules-new-test.c++ │ │ ├── modules-new.c++ │ │ ├── modules-new.h │ │ ├── modules.c++ │ │ ├── modules.capnp │ │ ├── modules.h │ │ ├── multiple-typewrappers-test.c++ │ │ ├── observer.h │ │ ├── promise-test.c++ │ │ ├── promise.c++ │ │ ├── promise.h │ │ ├── resource-test-bootstrap.js │ │ ├── resource-test-builtin.js │ │ ├── resource-test.c++ │ │ ├── resource-test.capnp │ │ ├── resource.c++ │ │ ├── resource.h │ │ ├── rtti-test.c++ │ │ ├── rtti-test.capnp │ │ ├── rtti.capnp │ │ ├── rtti.h │ │ ├── script.c++ │ │ ├── script.h │ │ ├── ser-test.c++ │ │ ├── ser.c++ │ │ ├── ser.h │ │ ├── setup-test.c++ │ │ ├── setup.c++ │ │ ├── setup.h │ │ ├── struct-test.c++ │ │ ├── struct.h │ │ ├── tracing-test.c++ │ │ ├── type-wrapper-test.c++ │ │ ├── type-wrapper.h │ │ ├── url-test.c++ │ │ ├── url.c++ │ │ ├── url.h │ │ ├── util-test.c++ │ │ ├── util.c++ │ │ ├── util.h │ │ ├── v8-platform-wrapper.c++ │ │ ├── v8-platform-wrapper.h │ │ ├── value-test.c++ │ │ ├── value.h │ │ ├── web-idl-test.c++ │ │ ├── web-idl.h │ │ ├── wrappable.c++ │ │ └── wrappable.h │ ├── server │ │ ├── BUILD.bazel │ │ ├── actor-id-impl-test.c++ │ │ ├── actor-id-impl.c++ │ │ ├── actor-id-impl.h │ │ ├── alarm-scheduler.c++ │ │ ├── alarm-scheduler.h │ │ ├── bundle-fs-test.c++ │ │ ├── bundle-fs.c++ │ │ ├── bundle-fs.h │ │ ├── fallback-service.c++ │ │ ├── fallback-service.h │ │ ├── server-test.c++ │ │ ├── server.c++ │ │ ├── server.h │ │ ├── tests │ │ │ ├── BUILD.bazel │ │ │ ├── compile-tests │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── compile-helloworld-test.ok │ │ │ │ └── compile-test.sh │ │ │ ├── extensions │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── binding.js │ │ │ │ ├── extension.capnp │ │ │ │ ├── extensions-test.js │ │ │ │ ├── extensions-test.wd-test │ │ │ │ ├── internal-module.js │ │ │ │ └── module.js │ │ │ ├── inspector │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── config.capnp │ │ │ │ ├── driver.mjs │ │ │ │ └── index.mjs │ │ │ ├── python │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── asgi-sse │ │ │ │ │ ├── asgi-sse.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── asgi │ │ │ │ │ ├── asgi.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── dont-snapshot-pyodide │ │ │ │ │ ├── dont-snapshot-pyodide.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── durable-object │ │ │ │ │ ├── durable-object.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── env-param │ │ │ │ │ ├── env.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── filter-non-py-files │ │ │ │ │ ├── filter-files.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── hello │ │ │ │ │ ├── hello.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── import_tests.bzl │ │ │ │ ├── importable-env │ │ │ │ │ ├── importable-env.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── js-import │ │ │ │ │ ├── js-import.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── jspi │ │ │ │ │ ├── jspi.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── py_wd_test.bzl │ │ │ │ ├── python-rpc │ │ │ │ │ ├── python-rpc.wd-test │ │ │ │ │ ├── worker.js │ │ │ │ │ └── worker.py │ │ │ │ ├── random │ │ │ │ │ ├── random.wd-test │ │ │ │ │ └── worker.py │ │ │ │ ├── sdk │ │ │ │ │ ├── proxy.js │ │ │ │ │ ├── sdk.wd-test │ │ │ │ │ ├── server.py │ │ │ │ │ └── worker.py │ │ │ │ ├── seek-metadatafs │ │ │ │ │ ├── a.py │ │ │ │ │ └── seek-metadatafs.wd-test │ │ │ │ ├── subdirectory │ │ │ │ │ ├── a.py │ │ │ │ │ ├── subdir │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ └── a.py │ │ │ │ │ └── subdirectory.wd-test │ │ │ │ ├── undefined-handler │ │ │ │ │ ├── main.py │ │ │ │ │ ├── server.mjs │ │ │ │ │ ├── undefined-handler.wd-test │ │ │ │ │ └── undefined_handler.py │ │ │ │ ├── vendor_dir │ │ │ │ │ ├── vendor │ │ │ │ │ │ └── a.py │ │ │ │ │ ├── vendor_dir.wd-test │ │ │ │ │ └── worker.py │ │ │ │ └── worker-entrypoint │ │ │ │ │ ├── worker-entrypoint.wd-test │ │ │ │ │ └── worker.py │ │ │ ├── server-harness.mjs │ │ │ ├── unsafe-eval │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── extension.capnp │ │ │ │ ├── module.js │ │ │ │ ├── unsafe-eval-test.js │ │ │ │ └── unsafe-eval-test.wd-test │ │ │ ├── unsafe-module │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── unsafe-module-test.js │ │ │ │ └── unsafe-module-test.wd-test │ │ │ └── weakref │ │ │ │ ├── BUILD.bazel │ │ │ │ ├── config.capnp │ │ │ │ ├── index.mjs │ │ │ │ └── test.mjs │ │ ├── v8-platform-impl.c++ │ │ ├── v8-platform-impl.h │ │ ├── workerd-api.c++ │ │ ├── workerd-api.h │ │ ├── workerd-meta.capnp │ │ ├── workerd.c++ │ │ └── workerd.capnp │ ├── tests │ │ ├── BUILD.bazel │ │ ├── bench-api-headers.c++ │ │ ├── bench-fast-api.c++ │ │ ├── bench-global-scope.c++ │ │ ├── bench-json.c++ │ │ ├── bench-kj-headers.c++ │ │ ├── bench-mimetype.c++ │ │ ├── bench-regex.c++ │ │ ├── bench-tools.h │ │ ├── performance-test.js │ │ ├── performance-test.wd-test │ │ ├── test-fixture-test.c++ │ │ ├── test-fixture.c++ │ │ ├── test-fixture.h │ │ ├── unknown-import-assertions-test.js │ │ └── unknown-import-assertions-test.wd-test │ ├── tools │ │ ├── BUILD.bazel │ │ ├── param-extractor.rs │ │ └── param-names-ast.c++ │ └── util │ │ ├── BUILD.bazel │ │ ├── abortable.h │ │ ├── account-limits.h │ │ ├── autogate.c++ │ │ ├── autogate.h │ │ ├── batch-queue-test.c++ │ │ ├── batch-queue.h │ │ ├── canceler.h │ │ ├── capnp-mock.c++ │ │ ├── capnp-mock.h │ │ ├── color-util.h │ │ ├── completion-membrane.h │ │ ├── duration-exceeded-logger-test.c++ │ │ ├── duration-exceeded-logger.h │ │ ├── exception.h │ │ ├── http-util.h │ │ ├── mimetype-test.c++ │ │ ├── mimetype.c++ │ │ ├── mimetype.h │ │ ├── own-util.h │ │ ├── perfetto-tracing.c++ │ │ ├── perfetto-tracing.h │ │ ├── sentry.h │ │ ├── sqlite-kv-test.c++ │ │ ├── sqlite-kv.c++ │ │ ├── sqlite-kv.h │ │ ├── sqlite-metadata-test.c++ │ │ ├── sqlite-metadata.c++ │ │ ├── sqlite-metadata.h │ │ ├── sqlite-test.c++ │ │ ├── sqlite.c++ │ │ ├── sqlite.h │ │ ├── stream-utils.c++ │ │ ├── stream-utils.h │ │ ├── string-buffer-test.c++ │ │ ├── string-buffer.h │ │ ├── strings.c++ │ │ ├── strings.h │ │ ├── test-test.c++ │ │ ├── test.h │ │ ├── thread-scopes.c++ │ │ ├── thread-scopes.h │ │ ├── uncaught-exception-source.h │ │ ├── use-perfetto-categories.h │ │ ├── uuid-test.c++ │ │ ├── uuid.c++ │ │ ├── uuid.h │ │ ├── wait-list-test.c++ │ │ ├── wait-list.c++ │ │ ├── wait-list.h │ │ ├── weak-refs.h │ │ ├── websocket-error-handler.c++ │ │ ├── websocket-error-handler.h │ │ └── xthreadnotifier.h └── wpt │ ├── BUILD.bazel │ ├── WebCryptoAPI-test.ts │ ├── compression-test.ts │ ├── dom │ ├── abort-test.ts │ └── events-test.ts │ ├── encoding-test.ts │ ├── eslint.config.mjs │ ├── fetch │ └── api-test.ts │ ├── harness │ ├── assertions.ts │ ├── common.ts │ ├── globals.ts │ ├── harness.ts │ ├── test.ts │ └── utils.ts │ ├── streams-test.ts │ ├── tsconfig.json │ ├── url-test.ts │ ├── urlpattern-standard-test.ts │ └── urlpattern-test.ts ├── tools ├── BUILD.bazel ├── base.eslint.config.mjs ├── cross │ ├── format.json │ ├── format.py │ └── internal_build.py ├── unix │ ├── apply-big-move.sh │ ├── clangd-check.sh │ ├── create-external.sh │ ├── create-internal-pr.sh │ ├── find-python3.sh │ ├── fix-copyrights.sh │ ├── upload-python-bundle.sh │ └── workspace-status.sh └── windows │ ├── bazel-env.bat │ ├── create-external.bat │ ├── install-deps.bat │ ├── vsconfig.json │ └── workspace-status.cmd └── types ├── BUILD.bazel ├── README.md ├── defines ├── ai.d.ts ├── aig.d.ts ├── autorag.d.ts ├── cf.d.ts ├── d1.d.ts ├── disposable.d.ts ├── email.d.ts ├── hyperdrive.d.ts ├── images.d.ts ├── pages.d.ts ├── pipelines.d.ts ├── pubsub.d.ts ├── ratelimit.d.ts ├── rpc.d.ts ├── secrets-store.d.ts ├── sockets.d.ts ├── trace.d.ts ├── vectorize.d.ts ├── versions.d.ts ├── wfp.d.ts └── workflows.d.ts ├── eslint.config.mjs ├── generated-snapshot ├── experimental │ ├── index.d.ts │ └── index.ts └── latest │ ├── index.d.ts │ └── index.ts ├── scripts ├── build-types.ts ├── build-worker.ts └── config.capnp ├── src ├── cloudflare.ts ├── generator │ ├── index.ts │ ├── parameter-names.ts │ ├── structure.ts │ └── type.ts ├── index.ts ├── print.ts ├── program.ts ├── standards.ts ├── transforms │ ├── ambient.ts │ ├── class-to-interface.ts │ ├── comments.ts │ ├── globals.ts │ ├── helpers.ts │ ├── import-resolve.ts │ ├── importable.ts │ ├── index.ts │ ├── internal-namespace.ts │ ├── iterators.ts │ ├── onmessage-declaration.ts │ └── overrides │ │ ├── compiler.ts │ │ └── index.ts ├── utils.ts └── worker │ ├── index.ts │ ├── raw.d.ts │ ├── rtti.d.ts │ └── virtual.d.ts ├── test ├── generator │ ├── index.spec.ts │ ├── structure.spec.ts │ └── type.spec.ts ├── index.spec.ts ├── print.spec.ts ├── transforms │ ├── class-to-interface.spec.ts │ ├── globals.spec.ts │ ├── iterators.spec.ts │ └── overrides │ │ └── index.spec.ts └── types │ ├── cf.ts │ ├── d1.ts │ ├── do.ts │ ├── rpc.ts │ └── tsconfig.json └── tsconfig.json /.bazelignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.bazelproject: -------------------------------------------------------------------------------- 1 | # For more documentation, please visit https://ij.bazel.build/docs/project-views.html 2 | 3 | directories: 4 | . 5 | -.devcontainer 6 | -.vscode 7 | -docs 8 | -githooks 9 | -samples 10 | 11 | derive_targets_from_directories: true 12 | 13 | additional_languages: 14 | typescript 15 | python 16 | javascript 17 | 18 | test_sources: 19 | src/workerd/tests/* 20 | src/workerd/api/node/tests/* 21 | src/workerd/api/tests/* 22 | src/workerd/api/*-test.js 23 | src/workerd/api/*-test.wd-test 24 | src/workerd/api/*-test.c++ 25 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 8.2.1 2 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Apply prettier to the project 2 | 0523bf8b36a937348f1bb79eceda2463a5c220b5 3 | 4 | # Apply clang-format to the project. 5 | 5e8537a77e760c160ace3dfe23ee8c76ee5aeeb3 6 | 7 | # Apply ruff format to the project 8 | d6d0607a845e6f71084ce272a1c1e8c50e244bdd 9 | 10 | # Apply buildifier to the project 11 | f457f19039b82536b35659c1f9cb898a198e6cd1 12 | 13 | # Apply ruff linter to the project 14 | 893774eab71fd7be5000436ff2ff0b5dd85ef073 15 | 16 | # Use clang-format to sort includes. 17 | faabf00af72bbce956221b40624f8a3d57f82b7c 18 | b9e9fb144f44494017e77fbe959355e92f10ae69 19 | 20 | # Add `AllowShortBlocksOnASingleLine: Empty` to clang-format 21 | fa2c488219a5e96792e61f3d51838595e2907c8d -------------------------------------------------------------------------------- /.github/DISCUSSION_TEMPLATE/nodejs_api_request.yml: -------------------------------------------------------------------------------- 1 | title: "Node.js API Request" 2 | labels: ["Node.js API Request"] 3 | body: 4 | - type: input 5 | id: module 6 | attributes: 7 | label: Module 8 | description: "Name of the Node.js module you want to work on Workers. Ex: fs" 9 | value: 10 | validations: 11 | required: true 12 | - type: input 13 | id: method 14 | attributes: 15 | label: API Method 16 | description: "Name of the specific API method you want to work on Workers. Ex: fs.readFile" 17 | value: 18 | validations: 19 | required: true 20 | - type: markdown 21 | id: context 22 | attributes: 23 | value: | 24 | ## Context 25 | -------------------------------------------------------------------------------- /.github/DISCUSSION_TEMPLATE/python_package_request.yml: -------------------------------------------------------------------------------- 1 | title: "Python Package Request" 2 | labels: ["Python Package Request"] 3 | body: 4 | - type: input 5 | id: package 6 | attributes: 7 | label: Package Name 8 | description: "Name of the Python package you want to work on Workers" 9 | value: 10 | validations: 11 | required: true 12 | - type: input 13 | id: version 14 | attributes: 15 | label: Package Version 16 | description: "Optional — specify a particular version of the package" 17 | value: 18 | validations: 19 | required: false 20 | - type: markdown 21 | id: context 22 | attributes: 23 | value: | 24 | ## Context 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/runtime-apis.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: runtime-apis 3 | about: Report an issue with an API provided by workerd 4 | title: '🐛 Bug Report — Runtime APIs' 5 | labels: runtime-api 6 | 7 | --- 8 | 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/workers-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: workers-types 3 | about: Report an issue or suggestion for `@cloudflare/workers-types` 4 | title: '' 5 | labels: types 6 | assignees: workers-devprod 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/workflows/fixup.yml: -------------------------------------------------------------------------------- 1 | name: "Just say no to fixup commits" 2 | on: 3 | workflow_call: 4 | 5 | jobs: 6 | block-fixup: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - name: Block Fixup Commit Merge 11 | uses: 13rac1/block-fixup-merge-action@v2.0.0 12 | 13 | -------------------------------------------------------------------------------- /.github/workflows/issues.yml: -------------------------------------------------------------------------------- 1 | name: Issue 2 | 3 | on: 4 | issues: 5 | types: [opened, labeled, transferred] 6 | 7 | jobs: 8 | add-to-project: 9 | name: Add issue to GH project 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/add-to-project@v1.0.2 13 | with: 14 | project-url: https://github.com/orgs/cloudflare/projects/1 15 | github-token: ${{ secrets.DEVPROD_PAT }} 16 | labeled: types 17 | -------------------------------------------------------------------------------- /.github/workflows/labels.yml: -------------------------------------------------------------------------------- 1 | # Based on https://www.neilmacy.co.uk/blog/github-action-to-block-merging 2 | name: "Internal PR Required" 3 | on: 4 | workflow_call: 5 | pull_request: 6 | types: [labeled, unlabeled] 7 | 8 | jobs: 9 | InternalPRRequired: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Check for label 13 | if: contains(github.event.*.labels.*.name, 'needs-internal-pr') 14 | run: | 15 | echo "Pull request is labeled as 'needs-internal-pr'" 16 | echo "This workflow fails so the pull request cannot be merged" 17 | exit 1 18 | -------------------------------------------------------------------------------- /.github/workflows/semgrep.yml: -------------------------------------------------------------------------------- 1 | 2 | on: 3 | workflow_dispatch: {} 4 | schedule: 5 | - cron: '0 0 * * *' 6 | name: Semgrep config 7 | jobs: 8 | semgrep: 9 | name: semgrep/ci 10 | runs-on: ubuntu-latest 11 | env: 12 | SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} 13 | SEMGREP_URL: https://cloudflare.semgrep.dev 14 | SEMGREP_APP_URL: https://cloudflare.semgrep.dev 15 | SEMGREP_VERSION_CHECK_URL: https://cloudflare.semgrep.dev/api/check-version 16 | container: 17 | image: semgrep/semgrep 18 | steps: 19 | - uses: actions/checkout@v4 20 | - run: semgrep ci 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # Ref: https://pnpm.io/npmrc#manage-package-manager-versions 2 | # When enabled, pnpm will automatically download and run the version of pnpm 3 | # specified in the packageManager field of package.json. 4 | manage-package-manager-versions = true 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | samples/nodejs-compat-streams-split2/split2.js 2 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "singleQuote": true, 5 | "trailingComma": "es5" 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "eamodio.gitlens", 4 | "llvm-vs-code-extensions.vscode-clangd", 5 | "ms-vscode.cpptools", 6 | "abronan.capnproto-syntax", 7 | "DavidAnson.vscode-markdownlint", 8 | "skellock.just" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /build/BUILD.ada-url: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "ada-url", 3 | srcs = ["ada.cpp"], 4 | hdrs = [ 5 | "ada.h", 6 | "ada_c.h", 7 | ], 8 | visibility = ["//visibility:public"], 9 | ) 10 | -------------------------------------------------------------------------------- /build/BUILD.all_pyodide_wheels: -------------------------------------------------------------------------------- 1 | filegroup( 2 | name = "whls", 3 | srcs = glob(["*"]), 4 | visibility = ["//visibility:public"], 5 | ) 6 | -------------------------------------------------------------------------------- /build/BUILD.nbytes: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "nbytes", 3 | srcs = ["src/nbytes.cpp"], 4 | hdrs = ["include/nbytes.h"], 5 | strip_include_prefix = "include", 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /build/BUILD.pyodide: -------------------------------------------------------------------------------- 1 | exports_files( 2 | glob( 3 | ["pyodide/*"], 4 | ), 5 | ) 6 | -------------------------------------------------------------------------------- /build/BUILD.pyodide_packages: -------------------------------------------------------------------------------- 1 | exports_files( 2 | glob(["*"]), 3 | ) 4 | -------------------------------------------------------------------------------- /build/BUILD.simdutf: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "simdutf", 3 | srcs = ["simdutf.cpp"], 4 | hdrs = ["simdutf.h"], 5 | copts = select({ 6 | # Enable SSE4.2 extensions, this reduces code size as the fallback code path for pre-Westmere 7 | # CPUs is no longer needed. 8 | "@platforms//cpu:x86_64": ["-msse4.2"], 9 | "//conditions:default": [], 10 | }) + ["-Wno-unused-function"], 11 | defines = ["SIMDUTF_ATOMIC_REF"], 12 | visibility = ["//visibility:public"], 13 | ) 14 | -------------------------------------------------------------------------------- /build/BUILD.wpt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017-2022 Cloudflare, Inc. 2 | # Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | # https://opensource.org/licenses/Apache-2.0 4 | 5 | load("@workerd//:build/wpt_get_directories.bzl", "wpt_all_dirs") 6 | load("@workerd//:build/wpt_test.bzl", "wpt_module", "wpt_server_entrypoint") 7 | 8 | [wpt_module( 9 | name = dir, 10 | ) for dir in wpt_all_dirs()] 11 | 12 | wpt_server_entrypoint( 13 | name = "entrypoint", 14 | srcs = ["wpt"] + glob(["**/*.py"]), 15 | python = "@python3_13_host//:python", 16 | visibility = ["//visibility:public"], 17 | ) 18 | 19 | exports_files([ 20 | "tools/certs/cacert.pem", 21 | ]) 22 | -------------------------------------------------------------------------------- /build/config/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_skylib//rules:common_settings.bzl", "string_flag") 2 | 3 | # Similar to --run_under flag to be able to run cross-compiled target binaries. 4 | string_flag( 5 | name = "target_run_under", 6 | build_setting_default = "", 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /build/deps/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudflare/workerd/a354d2e105621c5f87bd3a6e76a8e0fdcd4232e9/build/deps/BUILD -------------------------------------------------------------------------------- /build/deps/gen/dep_ada_url.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v3.2.4" 6 | URL = "https://github.com/ada-url/ada/releases/download/v3.2.4/singleheader.zip" 7 | STRIP_PREFIX = "" 8 | SHA256 = "bd89fcf57c93e965e6e2488448ab9d1cf8005311808c563b288f921d987e4924" 9 | TYPE = "zip" 10 | 11 | def dep_ada_url(): 12 | http_archive( 13 | name = "ada-url", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | build_file = "//:build/BUILD.ada-url", 19 | ) 20 | -------------------------------------------------------------------------------- /build/deps/gen/dep_aspect_rules_esbuild.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v0.22.1" 6 | URL = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.22.1/rules_esbuild-v0.22.1.tar.gz" 7 | STRIP_PREFIX = "rules_esbuild-0.22.1" 8 | SHA256 = "530adfeae30bbbd097e8af845a44a04b641b680c5703b3bf885cbd384ffec779" 9 | TYPE = "tgz" 10 | 11 | def dep_aspect_rules_esbuild(): 12 | http_archive( 13 | name = "aspect_rules_esbuild", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_aspect_rules_js.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v2.3.7" 6 | URL = "https://github.com/aspect-build/rules_js/releases/download/v2.3.7/rules_js-v2.3.7.tar.gz" 7 | STRIP_PREFIX = "rules_js-2.3.7" 8 | SHA256 = "83e5af4d17385d1c3268c31ae217dbfc8525aa7bcf52508dc6864baffc8b9501" 9 | TYPE = "tgz" 10 | 11 | def dep_aspect_rules_js(): 12 | http_archive( 13 | name = "aspect_rules_js", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_aspect_rules_ts.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v3.6.0" 6 | URL = "https://github.com/aspect-build/rules_ts/releases/download/v3.6.0/rules_ts-v3.6.0.tar.gz" 7 | STRIP_PREFIX = "rules_ts-3.6.0" 8 | SHA256 = "6b15ac1c69f2c0f1282e41ab469fd63cd40eb2e2d83075e19b68a6a76669773f" 9 | TYPE = "tgz" 10 | 11 | def dep_aspect_rules_ts(): 12 | http_archive( 13 | name = "aspect_rules_ts", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_bazel_skylib.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "1.7.1" 6 | URL = "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz" 7 | STRIP_PREFIX = "" 8 | SHA256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f" 9 | TYPE = "tgz" 10 | 11 | def dep_bazel_skylib(): 12 | http_archive( 13 | name = "bazel_skylib", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_brotli.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v1.1.0" 6 | URL = "https://api.github.com/repos/google/brotli/tarball/v1.1.0" 7 | STRIP_PREFIX = "google-brotli-ed738e8" 8 | SHA256 = "10973f4b4199eafa1d5735ef661ddb2ec2f97319ee9fd1824d4aabe08cff5265" 9 | TYPE = "tgz" 10 | 11 | def dep_brotli(): 12 | http_archive( 13 | name = "brotli", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_build_bazel_apple_support.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "1.22.0" 6 | URL = "https://github.com/bazelbuild/apple_support/releases/download/1.22.0/apple_support.1.22.0.tar.gz" 7 | STRIP_PREFIX = "./" 8 | SHA256 = "b265beacfa477081caaf2bd05978ee7d11fdb8c202a1b76d0ef28d901d1e7b33" 9 | TYPE = "tgz" 10 | 11 | def dep_build_bazel_apple_support(): 12 | http_archive( 13 | name = "build_bazel_apple_support", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_buildifier_darwin_amd64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "v8.2.0" 6 | URL = "https://github.com/bazelbuild/buildtools/releases/download/v8.2.0/buildifier-darwin-amd64" 7 | SHA256 = "309b3c3bfcc4b1533d5f7f796adbd266235cfb6f01450f3e37423527d209a309" 8 | 9 | def dep_buildifier_darwin_amd64(): 10 | http_file( 11 | name = "buildifier-darwin-amd64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_buildifier_darwin_arm64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "v8.2.0" 6 | URL = "https://github.com/bazelbuild/buildtools/releases/download/v8.2.0/buildifier-darwin-arm64" 7 | SHA256 = "e08381a3ed1d59c0a17d1cee1d4e7684c6ce1fc3b5cfa1bd92a5fe978b38b47d" 8 | 9 | def dep_buildifier_darwin_arm64(): 10 | http_file( 11 | name = "buildifier-darwin-arm64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_buildifier_linux_amd64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "v8.2.0" 6 | URL = "https://github.com/bazelbuild/buildtools/releases/download/v8.2.0/buildifier-linux-amd64" 7 | SHA256 = "3e79e6c0401b5f36f8df4dfc686127255d25c7eddc9599b8779b97b7ef4cdda7" 8 | 9 | def dep_buildifier_linux_amd64(): 10 | http_file( 11 | name = "buildifier-linux-amd64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_buildifier_linux_arm64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "v8.2.0" 6 | URL = "https://github.com/bazelbuild/buildtools/releases/download/v8.2.0/buildifier-linux-arm64" 7 | SHA256 = "c624a833bfa64d3a457ef0235eef0dbda03694768aab33f717a7ffd3f803d272" 8 | 9 | def dep_buildifier_linux_arm64(): 10 | http_file( 11 | name = "buildifier-linux-arm64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_buildifier_windows_amd64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "v8.2.0" 6 | URL = "https://github.com/bazelbuild/buildtools/releases/download/v8.2.0/buildifier-windows-amd64.exe" 7 | SHA256 = "a27fcf7521414f8214787989dcfb2ac7d3f7c28b56e44384e5fa06109953c2f1" 8 | 9 | def dep_buildifier_windows_amd64(): 10 | http_file( 11 | name = "buildifier-windows-amd64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_capnp_cpp.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | URL = "https://github.com/capnproto/capnproto/tarball/700968793550dc9c5d00aad0ea226d5904bb6d61" 6 | STRIP_PREFIX = "capnproto-capnproto-7009687/c++" 7 | SHA256 = "7d38ac925343b6383f0474affc6d7143310060824fc3f4939d3f764ffc775975" 8 | TYPE = "tgz" 9 | COMMIT = "700968793550dc9c5d00aad0ea226d5904bb6d61" 10 | 11 | def dep_capnp_cpp(): 12 | http_archive( 13 | name = "capnp-cpp", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_cargo_bazel_linux_arm64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "0.61.0" 6 | URL = "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/cargo-bazel-aarch64-unknown-linux-gnu" 7 | SHA256 = "6558d9840d62fdb2ef8e9c8e1388f4f66cd25dceaa6348d1f8f3dd7869e3e903" 8 | 9 | def dep_cargo_bazel_linux_arm64(): 10 | http_file( 11 | name = "cargo_bazel_linux_arm64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_cargo_bazel_linux_x64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "0.61.0" 6 | URL = "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/cargo-bazel-x86_64-unknown-linux-gnu" 7 | SHA256 = "90c4955085b1650e94e8ef220c0a536ec00b6564e28cb2665e4eab555eda19c9" 8 | 9 | def dep_cargo_bazel_linux_x64(): 10 | http_file( 11 | name = "cargo_bazel_linux_x64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_cargo_bazel_macos_arm64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "0.61.0" 6 | URL = "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/cargo-bazel-aarch64-apple-darwin" 7 | SHA256 = "a04d79154fabd906d816324314cb71c959458265eef90af18fbfe465b096a1db" 8 | 9 | def dep_cargo_bazel_macos_arm64(): 10 | http_file( 11 | name = "cargo_bazel_macos_arm64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_cargo_bazel_macos_x64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "0.61.0" 6 | URL = "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/cargo-bazel-x86_64-apple-darwin" 7 | SHA256 = "fb6895866f0c0510878a3477061434552010b08447d86c61beca3dce9721f791" 8 | 9 | def dep_cargo_bazel_macos_x64(): 10 | http_file( 11 | name = "cargo_bazel_macos_x64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_cargo_bazel_win_x64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "0.61.0" 6 | URL = "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/cargo-bazel-x86_64-pc-windows-msvc.exe" 7 | SHA256 = "50863a5d18d289161cebd639c6a0486a4c89828379481c91323fa69ecd23464a" 8 | 9 | def dep_cargo_bazel_win_x64(): 10 | http_file( 11 | name = "cargo_bazel_win_x64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | downloaded_file_path = "downloaded.exe", 16 | ) 17 | -------------------------------------------------------------------------------- /build/deps/gen/dep_clang_format_darwin_arm64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "llvm-18.1.8" 6 | URL = "https://github.com/cloudflare/workerd-tools/releases/download/llvm-18.1.8/llvm-18.1.8-darwin-arm64-clang-format" 7 | SHA256 = "08c90dad18580c61caed43b249704f4e8b1ca3dee6abb197185ecaef298149af" 8 | 9 | def dep_clang_format_darwin_arm64(): 10 | http_file( 11 | name = "clang-format-darwin-arm64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_clang_format_linux_amd64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "llvm-18.1.8" 6 | URL = "https://github.com/cloudflare/workerd-tools/releases/download/llvm-18.1.8/llvm-18.1.8-linux-amd64-clang-format" 7 | SHA256 = "34677b7593943121858197358481d6941d9be1977e024c9e21862bddef62c762" 8 | 9 | def dep_clang_format_linux_amd64(): 10 | http_file( 11 | name = "clang-format-linux-amd64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_clang_format_linux_arm64.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_file") 4 | 5 | TAG_NAME = "llvm-18.1.8" 6 | URL = "https://github.com/cloudflare/workerd-tools/releases/download/llvm-18.1.8/llvm-18.1.8-linux-arm64-clang-format" 7 | SHA256 = "e1eb317d1ccceb3d1b544a841bfb7a74a52969d8aa033f40b1796af3821c2a96" 8 | 9 | def dep_clang_format_linux_arm64(): 10 | http_file( 11 | name = "clang-format-linux-arm64", 12 | url = URL, 13 | executable = True, 14 | sha256 = SHA256, 15 | ) 16 | -------------------------------------------------------------------------------- /build/deps/gen/dep_com_google_benchmark.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v1.9.4" 6 | URL = "https://api.github.com/repos/google/benchmark/tarball/v1.9.4" 7 | STRIP_PREFIX = "google-benchmark-31c66f4" 8 | SHA256 = "5623f21dbb25028121c49b27a780c9bd688a866278cdbed0daf455330a183f03" 9 | TYPE = "tgz" 10 | 11 | def dep_com_google_benchmark(): 12 | http_archive( 13 | name = "com_google_benchmark", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_kj_rs.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | URL = "https://github.com/capnproto/kj-rs/tarball/3f0bc9b5e6e0b56a0fa43fd024c9a68601260ead" 6 | STRIP_PREFIX = "capnproto-kj-rs-3f0bc9b" 7 | SHA256 = "2b4cfd8f476c6e76cc8c49bdc7e0541c51f769b8d1adab1790a400222353a102" 8 | TYPE = "tgz" 9 | COMMIT = "3f0bc9b5e6e0b56a0fa43fd024c9a68601260ead" 10 | 11 | def dep_kj_rs(): 12 | http_archive( 13 | name = "kj-rs", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_rules_nodejs.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v6.4.0" 6 | URL = "https://github.com/bazel-contrib/rules_nodejs/releases/download/v6.4.0/rules_nodejs-v6.4.0.tar.gz" 7 | STRIP_PREFIX = "rules_nodejs-6.4.0" 8 | SHA256 = "8bfd114e95e88df5ecc66b03b726944f47a8b46db4b3b6ace87cfc316713bd1c" 9 | TYPE = "tgz" 10 | 11 | def dep_rules_nodejs(): 12 | http_archive( 13 | name = "rules_nodejs", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_rules_python.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "1.4.1" 6 | URL = "https://github.com/bazel-contrib/rules_python/releases/download/1.4.1/rules_python-1.4.1.tar.gz" 7 | STRIP_PREFIX = "rules_python-1.4.1" 8 | SHA256 = "9f9f3b300a9264e4c77999312ce663be5dee9a56e361a1f6fe7ec60e1beef9a3" 9 | TYPE = "tgz" 10 | 11 | def dep_rules_python(): 12 | http_archive( 13 | name = "rules_python", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_rules_rust.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "0.61.0" 6 | URL = "https://github.com/bazelbuild/rules_rust/releases/download/0.61.0/rules_rust-0.61.0.tar.gz" 7 | STRIP_PREFIX = "" 8 | SHA256 = "53c1bac7ec48f7ce48c4c1c6aa006f27515add2aeb05725937224e6e00ec7cea" 9 | TYPE = "tgz" 10 | 11 | def dep_rules_rust(): 12 | http_archive( 13 | name = "rules_rust", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_rules_shell.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v0.4.1" 6 | URL = "https://github.com/bazelbuild/rules_shell/releases/download/v0.4.1/rules_shell-v0.4.1.tar.gz" 7 | STRIP_PREFIX = "rules_shell-0.4.1" 8 | SHA256 = "bc61ef94facc78e20a645726f64756e5e285a045037c7a61f65af2941f4c25e1" 9 | TYPE = "tgz" 10 | 11 | def dep_rules_shell(): 12 | http_archive( 13 | name = "rules_shell", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_simdutf.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "v7.3.0" 6 | URL = "https://github.com/simdutf/simdutf/releases/download/v7.3.0/singleheader.zip" 7 | STRIP_PREFIX = "" 8 | SHA256 = "512374f8291d3daf102ccd0ad223b1a8318358f7c1295efd4d9a3abbb8e4b6ff" 9 | TYPE = "zip" 10 | 11 | def dep_simdutf(): 12 | http_archive( 13 | name = "simdutf", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | build_file = "//:build/BUILD.simdutf", 19 | ) 20 | -------------------------------------------------------------------------------- /build/deps/gen/dep_ssl.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | URL = "https://github.com/google/boringssl/tarball/6abe18402eb2a5e9b00158c6459646a948c53060" 6 | STRIP_PREFIX = "google-boringssl-6abe184" 7 | SHA256 = "76962c003a298f405d1a5d273a74a94f58b69f65d64b8574a82d4c21c5e407be" 8 | TYPE = "tgz" 9 | COMMIT = "6abe18402eb2a5e9b00158c6459646a948c53060" 10 | 11 | def dep_ssl(): 12 | http_archive( 13 | name = "ssl", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | ) 19 | -------------------------------------------------------------------------------- /build/deps/gen/dep_wpt.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//:build/http.bzl", "http_archive") 4 | 5 | TAG_NAME = "wpt-c1ad85a22" 6 | URL = "https://github.com/cloudflare/workerd-tools/releases/download/wpt-c1ad85a22/wpt-c1ad85a22.tar.gz" 7 | STRIP_PREFIX = "wpt-c1ad85a22" 8 | SHA256 = "b91e6024787d3c440525054fe161cdb1f28b6757613ef9ce1ab14685430d947c" 9 | TYPE = "tgz" 10 | 11 | def dep_wpt(): 12 | http_archive( 13 | name = "wpt", 14 | url = URL, 15 | strip_prefix = STRIP_PREFIX, 16 | type = TYPE, 17 | sha256 = SHA256, 18 | build_file = "@workerd//:build/BUILD.wpt", 19 | ) 20 | -------------------------------------------------------------------------------- /build/deps/gen/deps.bzl: -------------------------------------------------------------------------------- 1 | # WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT 2 | 3 | load("@//build/deps:gen/dep_ada_url.bzl", "dep_ada_url") 4 | load("@//build/deps:gen/dep_brotli.bzl", "dep_brotli") 5 | load("@//build/deps:gen/dep_capnp_cpp.bzl", "dep_capnp_cpp") 6 | load("@//build/deps:gen/dep_simdutf.bzl", "dep_simdutf") 7 | load("@//build/deps:gen/dep_ssl.bzl", "dep_ssl") 8 | 9 | def deps_gen(): 10 | dep_capnp_cpp() 11 | dep_ssl() 12 | dep_ada_url() 13 | dep_simdutf() 14 | dep_brotli() 15 | -------------------------------------------------------------------------------- /build/deps/requirements.in: -------------------------------------------------------------------------------- 1 | jinja2 2 | -------------------------------------------------------------------------------- /build/fixtures/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files(["kj_test.sh"]) 2 | -------------------------------------------------------------------------------- /build/fixtures/kj_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | "$@" 4 | -------------------------------------------------------------------------------- /build/http.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive", _http_file = "http_file") 2 | 3 | http_archive = _http_archive 4 | http_file = _http_file 5 | -------------------------------------------------------------------------------- /build/pyodide_bucket.bzl: -------------------------------------------------------------------------------- 1 | # Do not edit this file by hand. See docs/pyodide.md for info on how to generate it. 2 | # These variables are factored out here because they are being shared by the WORKSPACE files in 3 | # both edgeworker and workerd, as well as src/pyodide/BUILD.bazel 4 | PYODIDE_GITHUB_RELEASE_URL = "https://github.com/cloudflare/pyodide-build-scripts/releases/download/20240513.2/" 5 | PYODIDE_PACKAGES_TAR_ZIP_SHA256 = "b71d4c3cee3b6bd12969a788545f4159fb1eb984a7ca5de2493c4fa8479beeec" 6 | PYODIDE_ALL_WHEELS_ZIP_SHA256 = "c17feb45fdcb4b41eab9c719e69c9e062a8fc88344fcb6bbd7de0de92c3ae660" 7 | -------------------------------------------------------------------------------- /build/typescript.bzl: -------------------------------------------------------------------------------- 1 | def module_name(ts_name): 2 | if ts_name.endswith(".ts"): 3 | return ts_name.removesuffix(".ts") 4 | if ts_name.endswith(".mts"): 5 | return ts_name.removesuffix(".mts") 6 | fail("Expected TypeScript source file, got " + ts_name) 7 | 8 | def js_name(ts_name): 9 | if ts_name.endswith(".ts"): 10 | return ts_name.removesuffix(".ts") + ".js" 11 | if ts_name.endswith(".mts"): 12 | return ts_name.removesuffix(".mts") + ".mjs" 13 | fail("Expected TypeScript source file, got " + ts_name) 14 | -------------------------------------------------------------------------------- /build/wd_cc_capnp_library.bzl: -------------------------------------------------------------------------------- 1 | """wd_cc_capnp_library definition""" 2 | 3 | load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library") 4 | 5 | def wd_cc_capnp_library(**kwargs): 6 | """Wrapper for cc_capnp_library that sets common attributes 7 | """ 8 | cc_capnp_library( 9 | src_prefix = "src", 10 | strip_include_prefix = "/src", 11 | **kwargs 12 | ) 13 | -------------------------------------------------------------------------------- /build/wd_cc_library.bzl: -------------------------------------------------------------------------------- 1 | """wd_cc_library definition""" 2 | 3 | def wd_cc_library(strip_include_prefix = "/src", **kwargs): 4 | """Wrapper for cc_library that sets common attributes 5 | """ 6 | native.cc_library( 7 | strip_include_prefix = strip_include_prefix, 8 | **kwargs 9 | ) 10 | -------------------------------------------------------------------------------- /build/wd_rust_capnp_library.bzl: -------------------------------------------------------------------------------- 1 | """wd_rust_capnp_library definition""" 2 | 3 | load("@capnp-cpp//src/capnp:rust_capnp_library.bzl", "rust_capnp_library") 4 | 5 | def wd_rust_capnp_library(**kwargs): 6 | """Wrapper for rust_capnp_library that sets common attributes 7 | """ 8 | rust_capnp_library( 9 | src_prefix = "src", 10 | **kwargs 11 | ) 12 | -------------------------------------------------------------------------------- /build/wpt_get_directories.bzl: -------------------------------------------------------------------------------- 1 | def wpt_all_dirs(): 2 | always_exclude = [ 3 | ".*/**", # dotfiles 4 | "tools/**", # backend 5 | ] 6 | files = native.glob(["**/*"], exclude_directories = 1) 7 | return native.glob(["**/*"], exclude_directories = 0, exclude = files + always_exclude) 8 | -------------------------------------------------------------------------------- /deps/rust/BUILD.lolhtml: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "lolhtml", 3 | hdrs = ["@crates_vendor__lol_html_c_api-1.3.0//:include/lol_html.h"], 4 | strip_include_prefix = "include", 5 | visibility = ["//visibility:public"], 6 | deps = [ 7 | "@crates_vendor//:lol_html_c_api", 8 | ], 9 | ) 10 | -------------------------------------------------------------------------------- /docs/assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudflare/workerd/a354d2e105621c5f87bd3a6e76a8e0fdcd4232e9/docs/assets/banner.png -------------------------------------------------------------------------------- /docs/assets/vscode-dev-container-modal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudflare/workerd/a354d2e105621c5f87bd3a6e76a8e0fdcd4232e9/docs/assets/vscode-dev-container-modal.png -------------------------------------------------------------------------------- /docs/assets/vscode-dev-container-progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudflare/workerd/a354d2e105621c5f87bd3a6e76a8e0fdcd4232e9/docs/assets/vscode-dev-container-progress.png -------------------------------------------------------------------------------- /docs/benchmarking.md: -------------------------------------------------------------------------------- 1 | We use a combination of micro and macro benchmarks for performance testing workerd. 2 | 3 | # Building benchmarks 4 | 5 | Benchmarks should be built using `--config=benchmark` configuration, which is builds a release 6 | binary with additional debug info. 7 | 8 | To obtain most consistent results it is recommended to disable CPU frequency scaling 9 | (use "performance" governor https://wiki.debian.org/CpuFrequencyScaling) 10 | 11 | # Micro benchmarks 12 | 13 | Micro benchmarks are defined using `wd_cc_benchmark` bazel macro. Use `bazel run --config=benchmark` 14 | on a defined target to obtain benchmarking results. 15 | 16 | See example in [bench-json.c++](../src/workerd/tests/bench-json.c++) 17 | 18 | -------------------------------------------------------------------------------- /empty/empty: -------------------------------------------------------------------------------- 1 | This directory is used as the basis for a trivial BUILD file that just forwards elsewhere. We need 2 | an empty directory to feed into Bazel's new_local_repository rule. There is probably a better way 3 | to do this. 4 | -------------------------------------------------------------------------------- /githooks/README: -------------------------------------------------------------------------------- 1 | This directory should be configured as git hooks in the development environment. 2 | workspace-status.sh checks for this during each bazel build. 3 | -------------------------------------------------------------------------------- /npm/scripts/build-types-package.mjs: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import fs from "fs"; 3 | 4 | function buildTypesPackage() { 5 | const packageJsonPath = path.join("npm", "workers-types", "package.json"); 6 | const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); 7 | packageJson.version = process.env.WORKERD_VERSION; 8 | fs.writeFileSync( 9 | packageJsonPath, 10 | JSON.stringify(packageJson, null, 2) + "\n" 11 | ); 12 | } 13 | 14 | buildTypesPackage(); 15 | -------------------------------------------------------------------------------- /npm/workerd-darwin-64/README.md: -------------------------------------------------------------------------------- 1 | # 👷 `workerd` for macOS 64-bit, Cloudflare's JavaScript/Wasm Runtime 2 | 3 | `workerd` is a JavaScript / Wasm server runtime based on the same code that powers 4 | [Cloudflare Workers](https://workers.dev). 5 | 6 | See https://github.com/cloudflare/workerd for details. 7 | -------------------------------------------------------------------------------- /npm/workerd-darwin-64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cloudflare/workerd-darwin-64", 3 | "description": "👷 workerd for macOS 64-bit, Cloudflare's JavaScript/Wasm Runtime", 4 | "repository": "https://github.com/cloudflare/workerd", 5 | "license": "Apache-2.0", 6 | "preferUnplugged": false, 7 | "engines": { 8 | "node": ">=16" 9 | }, 10 | "os": [ 11 | "darwin" 12 | ], 13 | "cpu": [ 14 | "x64" 15 | ], 16 | "version": "1.20220926.0" 17 | } 18 | -------------------------------------------------------------------------------- /npm/workerd-darwin-arm64/README.md: -------------------------------------------------------------------------------- 1 | # 👷 `workerd` for macOS ARM 64-bit, Cloudflare's JavaScript/Wasm Runtime 2 | 3 | `workerd` is a JavaScript / Wasm server runtime based on the same code that powers 4 | [Cloudflare Workers](https://workers.dev). 5 | 6 | See https://github.com/cloudflare/workerd for details. 7 | -------------------------------------------------------------------------------- /npm/workerd-darwin-arm64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cloudflare/workerd-darwin-arm64", 3 | "description": "👷 workerd for macOS ARM 64-bit, Cloudflare's JavaScript/Wasm Runtime", 4 | "repository": "https://github.com/cloudflare/workerd", 5 | "license": "Apache-2.0", 6 | "preferUnplugged": false, 7 | "engines": { 8 | "node": ">=16" 9 | }, 10 | "os": [ 11 | "darwin" 12 | ], 13 | "cpu": [ 14 | "arm64" 15 | ], 16 | "version": "1.20220926.0" 17 | } 18 | -------------------------------------------------------------------------------- /npm/workerd-linux-64/README.md: -------------------------------------------------------------------------------- 1 | # 👷 `workerd` for Linux 64-bit, Cloudflare's JavaScript/Wasm Runtime 2 | 3 | `workerd` is a JavaScript / Wasm server runtime based on the same code that powers 4 | [Cloudflare Workers](https://workers.dev). 5 | 6 | See https://github.com/cloudflare/workerd for details. 7 | -------------------------------------------------------------------------------- /npm/workerd-linux-64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cloudflare/workerd-linux-64", 3 | "description": "👷 workerd for Linux 64-bit, Cloudflare's JavaScript/Wasm Runtime", 4 | "repository": "https://github.com/cloudflare/workerd", 5 | "license": "Apache-2.0", 6 | "preferUnplugged": false, 7 | "engines": { 8 | "node": ">=16" 9 | }, 10 | "os": [ 11 | "linux" 12 | ], 13 | "cpu": [ 14 | "x64" 15 | ], 16 | "version": "1.20220926.0" 17 | } 18 | -------------------------------------------------------------------------------- /npm/workerd-linux-arm64/README.md: -------------------------------------------------------------------------------- 1 | # 👷 `workerd` for Linux ARM 64-bit, Cloudflare's JavaScript/Wasm Runtime 2 | 3 | `workerd` is a JavaScript / Wasm server runtime based on the same code that powers 4 | [Cloudflare Workers](https://workers.dev). 5 | 6 | See https://github.com/cloudflare/workerd for details. 7 | -------------------------------------------------------------------------------- /npm/workerd-linux-arm64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cloudflare/workerd-linux-arm64", 3 | "description": "👷 workerd for Linux ARM 64-bit, Cloudflare's JavaScript/Wasm Runtime", 4 | "repository": "https://github.com/cloudflare/workerd", 5 | "license": "Apache-2.0", 6 | "preferUnplugged": false, 7 | "engines": { 8 | "node": ">=16" 9 | }, 10 | "os": [ 11 | "linux" 12 | ], 13 | "cpu": [ 14 | "arm64" 15 | ], 16 | "version": "1.20220926.0" 17 | } 18 | -------------------------------------------------------------------------------- /npm/workerd-windows-64/README.md: -------------------------------------------------------------------------------- 1 | # 👷 `workerd` for Windows 64-bit, Cloudflare's JavaScript/Wasm Runtime 2 | 3 | `workerd` is a JavaScript / Wasm server runtime based on the same code that powers 4 | [Cloudflare Workers](https://workers.dev). 5 | 6 | See https://github.com/cloudflare/workerd for details. 7 | -------------------------------------------------------------------------------- /npm/workerd-windows-64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cloudflare/workerd-windows-64", 3 | "description": "👷 workerd for Windows 64-bit, Cloudflare's JavaScript/Wasm Runtime", 4 | "repository": "https://github.com/cloudflare/workerd", 5 | "license": "Apache-2.0", 6 | "preferUnplugged": false, 7 | "engines": { 8 | "node": ">=16" 9 | }, 10 | "os": [ 11 | "win32" 12 | ], 13 | "cpu": [ 14 | "x64" 15 | ], 16 | "version": "1.20220926.0" 17 | } 18 | -------------------------------------------------------------------------------- /npm/workerd/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /npm/workerd/README.md: -------------------------------------------------------------------------------- 1 | # 👷 `workerd`, Cloudflare's JavaScript/Wasm Runtime 2 | 3 | `workerd` is a JavaScript / Wasm server runtime based on the same code that powers 4 | [Cloudflare Workers](https://workers.dev). 5 | 6 | See https://github.com/cloudflare/workerd for details. 7 | -------------------------------------------------------------------------------- /npm/workers-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cloudflare/workers-types", 3 | "description": "TypeScript typings for Cloudflare Workers", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/cloudflare/workerd" 7 | }, 8 | "author": "Cloudflare Workers DevProd Team (https://workers.cloudflare.com)", 9 | "license": "MIT OR Apache-2.0" 10 | } 11 | -------------------------------------------------------------------------------- /samples/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files([ 2 | "helloworld/config.capnp", 3 | "helloworld/worker.js", 4 | ]) 5 | -------------------------------------------------------------------------------- /samples/eventsource/README.md: -------------------------------------------------------------------------------- 1 | # EventSource Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/eventsource/config.capnp 13 | ``` 14 | -------------------------------------------------------------------------------- /samples/extensions/binding.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import { BurritoShop } from "burrito-shop-internal:burrito-shop-impl"; 6 | 7 | function makeBinding(env) { 8 | return new BurritoShop(env.recipes); 9 | } 10 | 11 | export default makeBinding; 12 | -------------------------------------------------------------------------------- /samples/extensions/burrito-shop.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | // implementation details are not directly accessible to the user 6 | import { BurritoShop } from "burrito-shop-internal:burrito-shop-impl"; 7 | 8 | export { BurritoShop }; 9 | -------------------------------------------------------------------------------- /samples/extensions/kitchen.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | // kitchen.js is an internal module and can't be imported by user code. 6 | 7 | const prices = { "rice": 1, "meat": 5, "beans": 1, "cheese": 1, "salsa": 1, "guacamole": 6, }; 8 | 9 | class Burrito { 10 | #recipe; 11 | constructor(recipe) { 12 | this.#recipe = recipe; 13 | } 14 | 15 | price() { 16 | return this.#recipe.reduce((acc, val) => acc + prices[val], 0); 17 | } 18 | }; 19 | 20 | export function makeBurritoImpl(recipe) { 21 | return new Burrito(recipe); 22 | } 23 | -------------------------------------------------------------------------------- /samples/extensions/recipes.json: -------------------------------------------------------------------------------- 1 | { 2 | "meat": ["rice", "meat", "beans", "cheese", "salsa"], 3 | "veggie": ["rice", "guacamole", "beans", "salsa"] 4 | } 5 | -------------------------------------------------------------------------------- /samples/hello-wasm/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | build 3 | -------------------------------------------------------------------------------- /samples/hello-wasm/README.md: -------------------------------------------------------------------------------- 1 | # Hello WASM Example 2 | 3 | ## Build WASM Binary 4 | 5 | ```sh 6 | $ cargo install worker-build 7 | $ worker-build --release 8 | ``` 9 | 10 | ## Run with `workerd` 11 | 12 | To run the example on http://localhost:8080 13 | 14 | ```sh 15 | $ ./workerd serve config.capnp 16 | ``` 17 | 18 | To run using bazel 19 | 20 | ```sh 21 | $ bazel run //src/workerd/server:workerd -- serve $(pwd)/samples/hello-wasm/config.capnp 22 | ``` 23 | 24 | To create a standalone binary that can be run: 25 | 26 | ```sh 27 | $ ./workerd compile config.capnp > hellowasm 28 | 29 | $ ./hellowasm 30 | ``` 31 | 32 | To test: 33 | 34 | ```sh 35 | % curl http://localhost:8080 36 | Hello WASM! 37 | ``` 38 | -------------------------------------------------------------------------------- /samples/hello-wasm/src/utils.rs: -------------------------------------------------------------------------------- 1 | use cfg_if::cfg_if; 2 | 3 | cfg_if! { 4 | // https://github.com/rustwasm/console_error_panic_hook#readme 5 | if #[cfg(feature = "console_error_panic_hook")] { 6 | extern crate console_error_panic_hook; 7 | pub use self::console_error_panic_hook::set_once as set_panic_hook; 8 | } else { 9 | #[inline] 10 | pub fn set_panic_hook() {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /samples/helloworld/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/helloworld/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > helloworld 19 | 20 | $ ./helloworld 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/helloworld/worker.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | addEventListener('fetch', event => { 6 | event.respondWith(handle(event.request)); 7 | }); 8 | 9 | async function handle(request) { 10 | return new Response("Hello World\n"); 11 | } 12 | -------------------------------------------------------------------------------- /samples/helloworld_esm/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/helloworld_esm/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > helloworld 19 | 20 | $ ./helloworld 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/helloworld_esm/worker.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export default { 6 | async fetch(req, env) { 7 | return new Response("Hello World\n"); 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /samples/memory-cache/README.md: -------------------------------------------------------------------------------- 1 | # Memory-Cache Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve --experimental config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/helloworld_esm/config.capnp --experimental 13 | ``` 14 | -------------------------------------------------------------------------------- /samples/memory-cache/worker.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export default { 6 | async fetch(req, env) { 7 | const cached = await env.CACHE.read("hello", async (key) => { 8 | return { 9 | value: 'World', 10 | expiration: Date.now() + 10000, 11 | }; 12 | }); 13 | 14 | return new Response(`Hello ${cached}\n`); 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /samples/module_fallback/README.md: -------------------------------------------------------------------------------- 1 | # Module Fallback Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/module_fallback/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > helloworld 19 | 20 | $ ./helloworld 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/module_fallback/cjs.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const vm = require('vm'); 3 | assert(vm !== undefined); 4 | 5 | module.exports = {}; 6 | -------------------------------------------------------------------------------- /samples/module_fallback/config.capnp: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const helloWorldExample :Workerd.Config = ( 4 | services = [ 5 | (name = "main", worker = .helloWorld), 6 | ], 7 | 8 | sockets = [ ( name = "http", address = "*:8080", http = (), service = "main" ) ] 9 | ); 10 | 11 | const helloWorld :Workerd.Worker = ( 12 | modules = [ 13 | (name = "worker", esModule = embed "worker.js"), 14 | (name = "cjs", commonJsModule = embed "cjs.js"), 15 | ], 16 | compatibilityDate = "2023-02-28", 17 | compatibilityFlags = ["nodejs_compat"], 18 | moduleFallback = "localhost:8888", 19 | ); 20 | -------------------------------------------------------------------------------- /samples/nodejs-compat-crypto/README.md: -------------------------------------------------------------------------------- 1 | # Node.js Compat Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/nodejs-compat/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > nodejs-compat 19 | 20 | $ ./nodejs-compat 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/nodejs-compat-diagnosticschannel/README.md: -------------------------------------------------------------------------------- 1 | # Node.js Compat Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/nodejs-compat/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > nodejs-compat 19 | 20 | $ ./nodejs-compat 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/nodejs-compat-diagnosticschannel/library.js: -------------------------------------------------------------------------------- 1 | import { channel } from "node:diagnostics_channel"; 2 | 3 | const theChannel = channel('test'); 4 | 5 | export function doSomething() { 6 | theChannel.publish('Hello from worker!'); 7 | } 8 | -------------------------------------------------------------------------------- /samples/nodejs-compat-streams/README.md: -------------------------------------------------------------------------------- 1 | # Node.js Compat Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/nodejs-compat/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > nodejs-compat 19 | 20 | $ ./nodejs-compat 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/nodejs-compat-streams/config.capnp: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const helloWorldExample :Workerd.Config = ( 4 | 5 | services = [ (name = "main", worker = .helloWorld) ], 6 | 7 | sockets = [ ( name = "http", address = "*:8080", http = (), service = "main" ) ] 8 | ); 9 | 10 | const helloWorld :Workerd.Worker = ( 11 | modules = [ 12 | (name = "worker", esModule = embed "worker.js") 13 | ], 14 | compatibilityDate = "2022-11-08", 15 | compatibilityFlags = ["nodejs_compat"] 16 | ); 17 | -------------------------------------------------------------------------------- /samples/nodejs-compat/README.md: -------------------------------------------------------------------------------- 1 | # Node.js Compat Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/nodejs-compat/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > nodejs-compat 19 | 20 | $ ./nodejs-compat 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /samples/pyodide-langchain/worker.py: -------------------------------------------------------------------------------- 1 | from langchain_core.prompts import PromptTemplate 2 | from langchain_openai import OpenAI 3 | 4 | API_KEY = "sk-abcdefg" 5 | 6 | 7 | async def test(request): 8 | prompt = PromptTemplate.from_template( 9 | "Complete the following sentence: I am a {profession} and " 10 | ) 11 | llm = OpenAI(api_key=API_KEY) 12 | chain = prompt | llm 13 | 14 | res = await chain.ainvoke({"profession": "electrician"}) 15 | print(res) 16 | -------------------------------------------------------------------------------- /samples/pyodide-secret/worker.py: -------------------------------------------------------------------------------- 1 | from js import Response 2 | 3 | 4 | def on_fetch(request, env): 5 | print(env.secret) 6 | return Response.new("hello world") 7 | 8 | 9 | def test(ctx, env): 10 | print(env.secret) 11 | print("Hi there, this is a test") 12 | -------------------------------------------------------------------------------- /samples/pyodide/worker.py: -------------------------------------------------------------------------------- 1 | from js import Response 2 | 3 | 4 | def on_fetch(request): 5 | return Response.new("hello world") 6 | 7 | 8 | def test(): 9 | print("Hi there, this is a test") 10 | -------------------------------------------------------------------------------- /samples/repl-server-python/README.md: -------------------------------------------------------------------------------- 1 | # REPL Server 2 | 3 | This sample creates a simple REPL server which communicates with a Node.js 4 | client over HTTP. This is very experimental and is only included for testing 5 | purposes for now. 6 | 7 | This sample is the Python variant of `repl-server`. 8 | 9 | ## How to use 10 | ``` 11 | ./bazel-bin/src/workerd/server/workerd serve samples/repl-server-python/config.capnp --experimental 12 | node samples/repl-server/client.js 13 | ``` 14 | -------------------------------------------------------------------------------- /samples/repl-server-python/client.js: -------------------------------------------------------------------------------- 1 | const repl = require("repl"); 2 | 3 | const myeval = async (cmd, ctx, fname, callback) => { 4 | const res = await fetch('http://localhost:8080', { 5 | method: 'POST', 6 | headers: { 7 | 'Accept': 'application/json', 8 | 'Content-Type': 'application/json' 9 | }, 10 | body: JSON.stringify({cmd}) 11 | }); 12 | 13 | callback(null, await res.text()); 14 | } 15 | 16 | repl.start({ 17 | eval: myeval, 18 | writer: a => a 19 | }); 20 | -------------------------------------------------------------------------------- /samples/repl-server-python/worker.py: -------------------------------------------------------------------------------- 1 | import code 2 | import sys 3 | from io import StringIO 4 | 5 | from js import Response 6 | 7 | sys.stdout = StringIO() 8 | 9 | ii = code.InteractiveInterpreter() 10 | 11 | 12 | async def on_fetch(request, env): 13 | cmd = (await request.json()).cmd 14 | 15 | ii.runsource(cmd) 16 | 17 | res = sys.stdout.getvalue() 18 | sys.stdout = StringIO() 19 | 20 | return Response.new(res) 21 | -------------------------------------------------------------------------------- /samples/repl-server/README.md: -------------------------------------------------------------------------------- 1 | # REPL Server 2 | 3 | This sample creates a simple REPL server which communicates with a Node.js 4 | client over HTTP. This is very experimental and is only included for testing 5 | purposes for now. 6 | 7 | ## How to use 8 | ``` 9 | ./bazel-bin/src/workerd/server/workerd serve samples/repl-server/config.capnp --experimental 10 | node samples/repl-server/client.js 11 | ``` 12 | -------------------------------------------------------------------------------- /samples/repl-server/client.js: -------------------------------------------------------------------------------- 1 | const repl = require("repl"); 2 | 3 | const myeval = async (cmd, ctx, fname, callback) => { 4 | const res = await fetch('http://localhost:8080', { 5 | method: 'POST', 6 | headers: { 7 | 'Accept': 'application/json', 8 | 'Content-Type': 'application/json' 9 | }, 10 | body: JSON.stringify({cmd}) 11 | }); 12 | 13 | callback(null, await res.text()); 14 | } 15 | 16 | repl.start({ 17 | eval: myeval, 18 | writer: a => a 19 | }); 20 | -------------------------------------------------------------------------------- /samples/repl-server/config.capnp: -------------------------------------------------------------------------------- 1 | 2 | using Workerd = import "/workerd/workerd.capnp"; 3 | 4 | const ReplServer :Workerd.Config = ( 5 | services = [ (name = "main", worker = .replServer) ], 6 | 7 | sockets = [ ( name = "http", address = "*:8080", http = (), service = "main" ) ] 8 | ); 9 | 10 | const replServer :Workerd.Worker = ( 11 | modules = [ 12 | (name = "worker", esModule = embed "worker.js") 13 | ], 14 | bindings = [ 15 | ( 16 | name = "secret", 17 | text = "thisisasecret" 18 | ), 19 | ], 20 | compatibilityDate = "2023-02-28", 21 | compatibilityFlags = ["nodejs_compat", "experimental", "unsafe_module"] 22 | ); 23 | -------------------------------------------------------------------------------- /samples/static-files-from-disk/content-dir/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Hello world!

6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/tail-workers/tail.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export default { 6 | // https://developers.cloudflare.com/workers/observability/logs/tail-workers/ 7 | tail(traces) { 8 | console.log(traces[0].logs); 9 | }, 10 | tailStream(...args) { 11 | console.log(...args); 12 | return (...args) => { 13 | console.log(...args); 14 | }; 15 | }, 16 | }; 17 | -------------------------------------------------------------------------------- /samples/tail-workers/worker.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export default { 6 | async fetch(req, env) { 7 | console.log('hello to the tail worker!'); 8 | reportError('boom'); 9 | reportError(new Error('test')); 10 | return new Response("Hello World\n"); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /samples/webfs/README.md: -------------------------------------------------------------------------------- 1 | # Web File System API Example 2 | 3 | To run the example on http://localhost:8080 4 | 5 | ```sh 6 | $ ./workerd serve config.capnp 7 | ``` 8 | 9 | To run using bazel 10 | 11 | ```sh 12 | $ bazel run //src/workerd/server:workerd -- serve ~/cloudflare/workerd/samples/helloworld_esm/config.capnp 13 | ``` 14 | 15 | To create a standalone binary that can be run: 16 | 17 | ```sh 18 | $ ./workerd compile config.capnp > helloworld 19 | 20 | $ ./helloworld 21 | ``` 22 | 23 | To test: 24 | 25 | ```sh 26 | % curl http://localhost:8080 27 | Hello World 28 | ``` 29 | -------------------------------------------------------------------------------- /src/cloudflare/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@workerd//:build/wd_ts_bundle.bzl", "wd_ts_bundle") 2 | 3 | wd_ts_bundle( 4 | name = "cloudflare", 5 | eslintrc_json = "eslint.config.mjs", 6 | import_name = "cloudflare", 7 | internal_modules = glob( 8 | [ 9 | "internal/*.ts", 10 | ], 11 | ), 12 | modules = glob( 13 | [ 14 | "*.ts", 15 | ], 16 | ), 17 | schema_id = "0xbcc8f57c63814006", 18 | tsconfig_json = "tsconfig.json", 19 | ) 20 | -------------------------------------------------------------------------------- /src/cloudflare/README.md: -------------------------------------------------------------------------------- 1 | # Cloudflare specific modules 2 | 3 | ## tests 4 | 5 | This codebase includes many unit tests. To run them, do: 6 | 7 | ``` 8 | bazel test --test_output=all //src/cloudflare/... 9 | ``` 10 | 11 | Running just a specific module tests: 12 | 13 | ``` 14 | bazel test --test_output=all //src/cloudflare/internal/test/aig/... 15 | ``` 16 | 17 | Running just eslint: 18 | 19 | ``` 20 | bazel test --test_output=all //src/cloudflare:cloudflare@eslint 21 | ``` 22 | 23 | ## Code formating 24 | 25 | You need to format your code before opening a pull request, otherwise the CI will fail: 26 | 27 | ``` 28 | prettier src/cloudflare -w 29 | prettier types/defines -w 30 | ``` 31 | -------------------------------------------------------------------------------- /src/cloudflare/ai.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export { 6 | AiOptions, 7 | InferenceUpstreamError, 8 | Ai, 9 | } from 'cloudflare-internal:ai-api'; 10 | 11 | export { 12 | AiGateway, 13 | AiGatewayInternalError, 14 | AiGatewayLogNotFound, 15 | } from 'cloudflare-internal:aig-api'; 16 | 17 | export { 18 | AutoRAG, 19 | AutoRAGInternalError, 20 | AutoRAGNotFoundError, 21 | AutoRAGUnauthorizedError, 22 | } from 'cloudflare-internal:autorag-api'; 23 | -------------------------------------------------------------------------------- /src/cloudflare/br.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | // This binding is managed by the browser rendering team (aka brapi) 6 | // https://developers.cloudflare.com/browser-rendering/ 7 | 8 | export { BrowserRendering } from 'cloudflare-internal:br-api'; 9 | -------------------------------------------------------------------------------- /src/cloudflare/email.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | // TODO: c++ built-ins do not yet support named exports 6 | import { default as email } from 'cloudflare-internal:email'; 7 | export const { EmailMessage } = email; 8 | -------------------------------------------------------------------------------- /src/cloudflare/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { baseConfig } from '../../tools/base.eslint.config.mjs'; 2 | 3 | export default baseConfig(); 4 | -------------------------------------------------------------------------------- /src/cloudflare/internal/email.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | // Type definitions for c++ implementation. 6 | 7 | export class EmailMessage { 8 | public constructor(from: string, to: string, raw: ReadableStream | string); 9 | public readonly from: string; 10 | public readonly to: string; 11 | } 12 | -------------------------------------------------------------------------------- /src/cloudflare/internal/env.d.ts: -------------------------------------------------------------------------------- 1 | // Get the current environment, if any 2 | export function getCurrent(): Record | undefined; 3 | export function withEnv(newEnv: unknown, fn: () => unknown): unknown; 4 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/ai/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test") 3 | 4 | wd_test( 5 | src = "ai-api-test.wd-test", 6 | args = ["--experimental"], 7 | data = glob(["*.js"]), 8 | ) 9 | 10 | py_wd_test( 11 | size = "large", 12 | src = "python-ai-api-test.wd-test", 13 | args = ["--experimental"], 14 | data = glob([ 15 | "*.js", 16 | "*.py", 17 | ]), 18 | # Works but times out frequently 19 | make_snapshot = False, 20 | ) 21 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/ai/ai-api-test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Cloudflare, Inc. 2 | # Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | # https://opensource.org/licenses/Apache-2.0 4 | 5 | 6 | async def test(context, env): 7 | resp = await env.ai.run("testModel", {"prompt": "test"}) 8 | assert resp.response == "model response" 9 | 10 | # Test request id is present 11 | assert env.ai.lastRequestId == "3a1983d7-1ddd-453a-ab75-c4358c91b582" 12 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/aig/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test") 3 | 4 | wd_test( 5 | src = "aig-api-test.wd-test", 6 | args = ["--experimental"], 7 | data = glob(["*.js"]), 8 | ) 9 | 10 | py_wd_test( 11 | size = "large", 12 | src = "python-aig-api-test.wd-test", 13 | args = ["--experimental"], 14 | data = glob([ 15 | "*.js", 16 | "*.py", 17 | ]), 18 | # Works but times out 19 | make_snapshot = False, 20 | ) 21 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/aig/aig-api-test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Cloudflare, Inc. 2 | # Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | # https://opensource.org/licenses/Apache-2.0 4 | 5 | 6 | async def test(context, env): 7 | resp = await env.ai.gateway("my-gateway").getLog("my-log-123") 8 | assert resp.cached is False 9 | assert resp.model == "string" 10 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/autorag/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test") 3 | 4 | wd_test( 5 | src = "autorag-api-test.wd-test", 6 | args = ["--experimental"], 7 | data = glob(["*.js"]), 8 | ) 9 | 10 | py_wd_test( 11 | size = "large", 12 | src = "python-autorag-api-test.wd-test", 13 | args = ["--experimental"], 14 | data = glob([ 15 | "*.js", 16 | "*.py", 17 | ]), 18 | # Works but times out 19 | make_snapshot = False, 20 | ) 21 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/autorag/autorag-api-test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Cloudflare, Inc. 2 | # Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | # https://opensource.org/licenses/Apache-2.0 4 | 5 | 6 | async def test(context, env): 7 | resp = await env.ai.autorag("my-rag").aiSearch({"query": "example query"}) 8 | assert resp.response == "this is an example result" 9 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/br/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test") 3 | 4 | wd_test( 5 | src = "br-api-test.wd-test", 6 | args = ["--experimental"], 7 | data = glob(["*.js"]), 8 | ) 9 | 10 | py_wd_test( 11 | size = "large", 12 | src = "python-br-api-test.wd-test", 13 | args = ["--experimental"], 14 | data = glob([ 15 | "*.js", 16 | "*.py", 17 | ]), 18 | # Works but times out 19 | make_snapshot = False, 20 | ) 21 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/br/br-api-test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Cloudflare, Inc. 2 | # Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | # https://opensource.org/licenses/Apache-2.0 4 | 5 | 6 | async def test(context, env): 7 | resp = await env.browser.fetch("http://workers-binding.brapi/run") 8 | data = await resp.json() 9 | assert data.success is True 10 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/br/br-mock.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export default { 6 | async fetch(request, env, ctx) { 7 | return Response.json( 8 | { success: true }, 9 | { 10 | headers: { 11 | 'content-type': 'application/json', 12 | }, 13 | } 14 | ); 15 | }, 16 | }; 17 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/d1/d1-api-test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import { testD1ApiQueriesHappyPath } from './d1-api-test-common'; 6 | 7 | export const testWithoutSessions = { 8 | async test(_ctr, env) { 9 | await testD1ApiQueriesHappyPath(env.d1); 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/images/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | 3 | wd_test( 4 | src = "images-api-test.wd-test", 5 | data = glob(["*.js"]), 6 | ) 7 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/pipeline-transform/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | 3 | wd_test( 4 | size = "large", 5 | src = "transform.wd-test", 6 | args = ["--experimental"], 7 | data = glob(["*.js"]), 8 | ) 9 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/pipeline-transform/transform.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "transform-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "transform-test.js") 9 | ], 10 | compatibilityDate = "2024-08-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ) 14 | ] 15 | ); 16 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/vectorize/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test") 3 | 4 | wd_test( 5 | src = "vectorize-api-test.wd-test", 6 | data = glob(["*.js"]), 7 | ) 8 | 9 | py_wd_test( 10 | size = "large", 11 | src = "python-vectorize-api-test.wd-test", 12 | data = glob([ 13 | "*.py", 14 | "*.js", 15 | ]), 16 | # Works but times out 17 | make_snapshot = False, 18 | ) 19 | -------------------------------------------------------------------------------- /src/cloudflare/internal/test/workflows/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | 3 | wd_test( 4 | src = "workflows-api-test.wd-test", 5 | args = ["--experimental"], 6 | data = glob(["*.js"]), 7 | ) 8 | -------------------------------------------------------------------------------- /src/cloudflare/internal/workers.d.ts: -------------------------------------------------------------------------------- 1 | export class DurableObject { 2 | public constructor(ctx: unknown, env: unknown); 3 | 4 | public ctx: unknown; 5 | public env: unknown; 6 | } 7 | 8 | export class WorkerEntrypoint { 9 | public constructor(ctx: unknown, env: unknown); 10 | 11 | public ctx: unknown; 12 | public env: unknown; 13 | } 14 | 15 | export class WorkflowEntrypoint { 16 | public constructor(ctx: unknown, env: unknown); 17 | 18 | public ctx: unknown; 19 | public env: unknown; 20 | } 21 | 22 | export class RpcStub { 23 | public constructor(server: object); 24 | } 25 | 26 | export class RpcTarget {} 27 | -------------------------------------------------------------------------------- /src/cloudflare/pipelines.ts: -------------------------------------------------------------------------------- 1 | import { PipelineTransformImpl } from 'cloudflare-internal:pipeline-transform'; 2 | 3 | export const PipelineTransformationEntrypoint = PipelineTransformImpl; 4 | -------------------------------------------------------------------------------- /src/cloudflare/sockets.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | // TODO: c++ built-ins do not yet support named exports 6 | import sockets from 'cloudflare-internal:sockets'; 7 | export function connect( 8 | address: string | sockets.SocketAddress, 9 | options: sockets.SocketOptions 10 | ): sockets.Socket { 11 | return sockets.connect(address, options); 12 | } 13 | -------------------------------------------------------------------------------- /src/cloudflare/workflows.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export { NonRetryableError } from 'cloudflare-internal:workflows-api'; 6 | -------------------------------------------------------------------------------- /src/node/_http_outgoing.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // Copyright Joyent and Node contributors. All rights reserved. MIT license. 5 | 6 | import { 7 | validateHeaderName, 8 | validateHeaderValue, 9 | } from 'node-internal:internal_http'; 10 | 11 | export { validateHeaderName, validateHeaderValue }; 12 | export default { 13 | validateHeaderName, 14 | validateHeaderValue, 15 | }; 16 | -------------------------------------------------------------------------------- /src/node/_stream_duplex.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | /* eslint-disable */ 6 | 7 | // prettier-ignore 8 | import { 9 | Duplex, 10 | from, 11 | fromWeb, 12 | toWeb, 13 | } from 'node-internal:streams_duplex'; 14 | 15 | // prettier-ignore 16 | export { 17 | Duplex, 18 | from, 19 | fromWeb, 20 | toWeb, 21 | }; 22 | export default Duplex; 23 | -------------------------------------------------------------------------------- /src/node/_stream_passthrough.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | /* eslint-disable */ 6 | import { PassThrough } from 'node-internal:streams_transform'; 7 | export { PassThrough }; 8 | export default PassThrough; 9 | -------------------------------------------------------------------------------- /src/node/_stream_readable.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | /* eslint-disable */ 6 | 7 | // prettier-ignore 8 | import { 9 | Readable, 10 | ReadableState, 11 | toWeb, 12 | fromWeb, 13 | from, 14 | wrap, 15 | } from 'node-internal:streams_readable'; 16 | 17 | // prettier-ignore 18 | export { 19 | Readable, 20 | ReadableState, 21 | toWeb, 22 | fromWeb, 23 | from, 24 | wrap, 25 | }; 26 | export default Readable; 27 | -------------------------------------------------------------------------------- /src/node/_stream_transform.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | /* eslint-disable */ 6 | import { Transform } from 'node-internal:streams_transform'; 7 | export { Transform }; 8 | export default Transform; 9 | -------------------------------------------------------------------------------- /src/node/_stream_writable.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | /* eslint-disable */ 6 | 7 | // prettier-ignore 8 | import { 9 | Writable, 10 | WritableState, 11 | fromWeb, 12 | toWeb, 13 | } from 'node-internal:streams_writable'; 14 | 15 | // prettier-ignore 16 | export { 17 | Writable, 18 | WritableState, 19 | fromWeb, 20 | toWeb, 21 | }; 22 | export default Writable; 23 | -------------------------------------------------------------------------------- /src/node/assert.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export * from 'node-internal:internal_assert'; 6 | import { default as assert } from 'node-internal:internal_assert'; 7 | export default assert; 8 | -------------------------------------------------------------------------------- /src/node/assert/strict.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export * from 'node-internal:internal_assert'; 6 | import { default as assert } from 'node-internal:internal_assert'; 7 | export default assert; 8 | -------------------------------------------------------------------------------- /src/node/dns/promises.ts: -------------------------------------------------------------------------------- 1 | import * as dns from 'node-internal:internal_dns_promises'; 2 | 3 | export * from 'node-internal:internal_dns_promises'; 4 | export default dns; 5 | -------------------------------------------------------------------------------- /src/node/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { baseConfig } from '../../tools/base.eslint.config.mjs'; 2 | 3 | export default baseConfig(); 4 | -------------------------------------------------------------------------------- /src/node/events.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | 6 | export * from 'node-internal:events'; 7 | export { default } from 'node-internal:events'; 8 | -------------------------------------------------------------------------------- /src/node/fs/promises.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import * as fs from 'node-internal:internal_fs_promises'; 6 | import * as constants from 'node-internal:internal_fs_constants'; 7 | 8 | export * from 'node-internal:internal_fs_promises'; 9 | export { constants }; 10 | 11 | export default { 12 | constants, 13 | ...fs, 14 | }; 15 | -------------------------------------------------------------------------------- /src/node/http.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // Copyright Joyent and Node contributors. All rights reserved. MIT license. 5 | 6 | import { 7 | validateHeaderName, 8 | validateHeaderValue, 9 | } from 'node-internal:internal_http'; 10 | import { METHODS, STATUS_CODES } from 'node-internal:internal_http_constants'; 11 | 12 | export { validateHeaderName, validateHeaderValue, METHODS, STATUS_CODES }; 13 | export default { 14 | validateHeaderName, 15 | validateHeaderValue, 16 | METHODS, 17 | STATUS_CODES, 18 | }; 19 | -------------------------------------------------------------------------------- /src/node/internal/dns.d.ts: -------------------------------------------------------------------------------- 1 | export function parseCaaRecord(record: string): { 2 | critical: number; 3 | field: 'issue' | 'iodef' | 'issuewild'; 4 | value: string; 5 | }; 6 | 7 | export function parseNaptrRecord(record: string): { 8 | flags: string; 9 | service: string; 10 | regexp: string; 11 | replacement: string; 12 | order: number; 13 | preference: number; 14 | }; 15 | -------------------------------------------------------------------------------- /src/node/internal/internal_tls_constants.ts: -------------------------------------------------------------------------------- 1 | // Allow {CLIENT_RENEG_LIMIT} client-initiated session renegotiations 2 | // every {CLIENT_RENEG_WINDOW} seconds. An error event is emitted if more 3 | // renegotiations are seen. The settings are applied to all remote client 4 | // connections. 5 | export const CLIENT_RENEG_LIMIT = 3; 6 | export const CLIENT_RENEG_WINDOW = 600; 7 | export const DEFAULT_CIPHERS = ''; 8 | export const DEFAULT_ECDH_CURVE = 'auto'; 9 | export const DEFAULT_MIN_VERSION = 'TLSv1.2'; 10 | export const DEFAULT_MAX_VERSION = 'TLSv1.3'; 11 | export const rootCertificates = []; 12 | -------------------------------------------------------------------------------- /src/node/internal/module.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export function createRequire(path: string): (specifier: string) => unknown; 6 | export function isBuiltin(specifier: string): boolean; 7 | -------------------------------------------------------------------------------- /src/node/internal/streams_duplex.d.ts: -------------------------------------------------------------------------------- 1 | import type { Duplex } from 'node:stream'; 2 | export { 3 | Duplex, 4 | Writable, 5 | WritableOptions, 6 | Readable, 7 | ReadableOptions, 8 | duplexPair, 9 | } from 'node:stream'; 10 | 11 | export function toBYOBWeb(duplex: Duplex): { 12 | readable: ReadableStream; 13 | writable: WritableStream; 14 | }; 15 | -------------------------------------------------------------------------------- /src/node/internal/streams_readable.d.ts: -------------------------------------------------------------------------------- 1 | import { Readable } from 'node:stream'; 2 | 3 | export { Readable }; 4 | -------------------------------------------------------------------------------- /src/node/internal/streams_util.d.ts: -------------------------------------------------------------------------------- 1 | import type { FinishedOptions } from 'node:stream'; 2 | 3 | type FinishedStream = 4 | | NodeJS.ReadableStream 5 | | NodeJS.WritableStream 6 | | NodeJS.ReadWriteStream; 7 | type FinishedCallback = (err?: NodeJS.ErrnoException | null) => void; 8 | 9 | export function eos(stream: FinishedStream, options: FinishedOptions): void; 10 | export function eos( 11 | stream: FinishedStream, 12 | options: FinishedOptions, 13 | callback?: FinishedCallback 14 | ): void; 15 | export function eos(stream: FinishedStream, callback?: FinishedCallback): void; 16 | -------------------------------------------------------------------------------- /src/node/internal/timers.d.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | setImmediate as setImmediateImpl, 3 | clearImmediate as clearImmediateImpl, 4 | } from 'node:timers'; 5 | 6 | export const setImmediate: typeof setImmediateImpl; 7 | export const clearImmediate: typeof clearImmediateImpl; 8 | -------------------------------------------------------------------------------- /src/node/internal/url.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | export function domainToASCII(domain: string): string; 5 | export function domainToUnicode(domain: string): string; 6 | export function format( 7 | href: string, 8 | hash: boolean, 9 | unicode: boolean, 10 | search: boolean, 11 | auth: boolean 12 | ): string; 13 | export function toASCII(input: string): string; 14 | export function canonicalizeIp(input: string): string; 15 | -------------------------------------------------------------------------------- /src/node/internal/workers.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace _default { 2 | class WorkerEntrypoint {} 3 | class WorkflowEntrypoint {} 4 | class DurableObject {} 5 | class RpcPromise {} 6 | class RpcProperty {} 7 | class RpcStub {} 8 | class RpcTarget {} 9 | } 10 | export default _default; 11 | -------------------------------------------------------------------------------- /src/node/process.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | 6 | export * from 'node-internal:process'; 7 | export { default } from 'node-internal:process'; 8 | -------------------------------------------------------------------------------- /src/node/stream/promises.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | // 5 | import { promises } from 'node-internal:streams_promises'; 6 | export * from 'node-internal:streams_promises'; 7 | export default promises; 8 | -------------------------------------------------------------------------------- /src/node/string_decoder.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import { StringDecoder } from 'node-internal:internal_stringdecoder'; 6 | export { StringDecoder }; 7 | export default { StringDecoder }; 8 | -------------------------------------------------------------------------------- /src/node/test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | import { MockTracker, MockFunctionContext } from 'node-internal:mock'; 5 | 6 | const mock = new MockTracker(); 7 | 8 | export { mock, MockFunctionContext, MockTracker }; 9 | export default { 10 | mock, 11 | MockFunctionContext, 12 | MockTracker, 13 | }; 14 | -------------------------------------------------------------------------------- /src/node/timers.ts: -------------------------------------------------------------------------------- 1 | import * as _promises from 'node-internal:internal_timers_promises'; 2 | import { 3 | setTimeout, 4 | clearTimeout, 5 | setImmediate, 6 | clearImmediate, 7 | setInterval, 8 | clearInterval, 9 | active, 10 | unenroll, 11 | enroll, 12 | } from 'node-internal:internal_timers'; 13 | 14 | export * from 'node-internal:internal_timers'; 15 | export const promises = _promises; 16 | 17 | export default { 18 | promises: _promises, 19 | setTimeout, 20 | clearTimeout, 21 | setImmediate, 22 | clearImmediate, 23 | setInterval, 24 | clearInterval, 25 | active, 26 | unenroll, 27 | enroll, 28 | }; 29 | -------------------------------------------------------------------------------- /src/pyodide/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { baseConfig } from '../../tools/base.eslint.config.mjs'; 2 | 3 | export default [ 4 | ...baseConfig(), 5 | { 6 | rules: { 7 | '@typescript-eslint/no-explicit-any': 'off', 8 | '@typescript-eslint/no-non-null-assertion': 'off', 9 | '@typescript-eslint/no-unnecessary-condition': 'off', 10 | }, 11 | }, 12 | ]; 13 | -------------------------------------------------------------------------------- /src/pyodide/internal/jaeger.ts: -------------------------------------------------------------------------------- 1 | import { default as internalJaeger } from 'pyodide-internal:internalJaeger'; 2 | 3 | /** 4 | * Used for tracing via Jaeger. 5 | */ 6 | export function enterJaegerSpan(span: string, callback: () => T): T { 7 | if (!internalJaeger.traceId) { 8 | // Jaeger tracing not enabled or traceId is not present in request. 9 | return callback(); 10 | } 11 | 12 | return internalJaeger.enterSpan(span, callback); 13 | } 14 | -------------------------------------------------------------------------------- /src/pyodide/internal/sphinx/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /src/pyodide/internal/sphinx/README.md: -------------------------------------------------------------------------------- 1 | ## Python SDK docs markdown generator 2 | 3 | This directory contains config files for Sphinx, which can generate docs based on the exported methods in asgi.py and workers.py. These files are a part of the Python SDK. 4 | 5 | ### Usage 6 | 7 | 8 | ``` 9 | python -m venv .venv 10 | source .venv/bin/activate 11 | pip install -r requirements-doc.txt 12 | make markdown 13 | ``` 14 | 15 | You'll then find the markdown in _build/markdown/docs/workers.md. 16 | 17 | Make a PR in the cloudflare-docs repo to update the appropriate files. 18 | -------------------------------------------------------------------------------- /src/pyodide/internal/sphinx/docs/asgi.rst: -------------------------------------------------------------------------------- 1 | asgi module 2 | =========== 3 | 4 | .. automodule:: asgi 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /src/pyodide/internal/sphinx/docs/modules.rst: -------------------------------------------------------------------------------- 1 | SDK 2 | === 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | asgi 8 | workers 9 | -------------------------------------------------------------------------------- /src/pyodide/internal/sphinx/docs/workers.rst: -------------------------------------------------------------------------------- 1 | workers module 2 | ============== 3 | 4 | .. automodule:: workers 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /src/pyodide/internal/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | .. Python Workers API documentation master file, created by 2 | sphinx-quickstart on Tue Jan 7 15:01:02 2025. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Python Workers API documentation 7 | ================================ 8 | 9 | Add your content using ``reStructuredText`` syntax. See the 10 | `reStructuredText `_ 11 | documentation for details. 12 | 13 | 14 | .. toctree:: 15 | :maxdepth: 2 16 | :caption: Contents: 17 | 18 | -------------------------------------------------------------------------------- /src/pyodide/internal/topLevelEntropy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudflare/workerd/a354d2e105621c5f87bd3a6e76a8e0fdcd4232e9/src/pyodide/internal/topLevelEntropy/__init__.py -------------------------------------------------------------------------------- /src/pyodide/internal/topLevelEntropy/entropy_import_context.py.d.ts: -------------------------------------------------------------------------------- 1 | declare const buf: ArrayBuffer; 2 | export default buf; 3 | -------------------------------------------------------------------------------- /src/pyodide/internal/topLevelEntropy/entropy_patches.py.d.ts: -------------------------------------------------------------------------------- 1 | declare const buf: ArrayBuffer; 2 | export default buf; 3 | -------------------------------------------------------------------------------- /src/pyodide/internal/topLevelEntropy/import_patch_manager.py.d.ts: -------------------------------------------------------------------------------- 1 | declare const buf: ArrayBuffer; 2 | export default buf; 3 | -------------------------------------------------------------------------------- /src/pyodide/types/Error.d.ts: -------------------------------------------------------------------------------- 1 | interface ErrorConstructor { 2 | prepareStackTrace: ((_error: Error, stack: StackItem[]) => void) | undefined; 3 | stackTraceLimit: number; 4 | } 5 | 6 | interface StackItem { 7 | getFunctionName: () => string; 8 | getFileName: () => string; 9 | } 10 | -------------------------------------------------------------------------------- /src/pyodide/types/artifacts.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace ArtifactBundler { 2 | type MemorySnapshotResult = { 3 | snapshot: Uint8Array; 4 | importedModulesList: string[]; 5 | }; 6 | 7 | const hasMemorySnapshot: () => boolean; 8 | const isEwValidating: () => boolean; 9 | const readMemorySnapshot: ( 10 | offset: number, 11 | buf: Uint32Array | Uint8Array 12 | ) => void; 13 | const getMemorySnapshotSize: () => number; 14 | const disposeMemorySnapshot: () => void; 15 | const storeMemorySnapshot: (snap: MemorySnapshotResult) => void; 16 | const getPackage: (path: string) => Reader | null; 17 | } 18 | 19 | export default ArtifactBundler; 20 | -------------------------------------------------------------------------------- /src/pyodide/types/disk_cache.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace DiskCache { 2 | const get: (key: string) => ArrayBuffer | null; 3 | const put: (key: string, val: ArrayBuffer) => void; 4 | } 5 | 6 | export default DiskCache; 7 | -------------------------------------------------------------------------------- /src/pyodide/types/internalJaeger.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace internalJaeger { 2 | const traceId: number | null, 3 | enterSpan: (name: string, callback: () => T) => T; 4 | } 5 | 6 | export default internalJaeger; 7 | -------------------------------------------------------------------------------- /src/pyodide/types/limiter.d.ts: -------------------------------------------------------------------------------- 1 | // A typescript declaration file for the internal Limiter JSG class 2 | // see src/workerd/api/pyodide/pyodide.h (SimplePythonLimiter) 3 | 4 | interface Limiter { 5 | beginStartup: () => void; 6 | finishStartup: () => void; 7 | } 8 | 9 | declare const limiter: Limiter; 10 | 11 | export default limiter; 12 | -------------------------------------------------------------------------------- /src/pyodide/types/modules.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'pyodide-internal:introspection.py' { 2 | const value: Uint8Array; 3 | export default value; 4 | } 5 | -------------------------------------------------------------------------------- /src/pyodide/types/packages_tar_reader.d.ts: -------------------------------------------------------------------------------- 1 | declare const TarReader: Reader; 2 | 3 | export default TarReader; 4 | -------------------------------------------------------------------------------- /src/pyodide/types/pyodide-lock.d.ts: -------------------------------------------------------------------------------- 1 | type InstallDir = 'site' | 'stdlib' | 'dynlib'; 2 | interface PackageDeclaration { 3 | depends: string[]; 4 | file_name: string; 5 | imports: string[]; 6 | install_dir: InstallDir; 7 | name: string; 8 | package_type: string; 9 | sha256: string; 10 | shared_library: boolean; 11 | unvendored_tests: boolean; 12 | version: string; 13 | } 14 | 15 | interface PackageLock { 16 | packages: { 17 | [id: string]: PackageDeclaration; 18 | }; 19 | } 20 | 21 | declare module 'pyodide-internal:generated/pyodide-lock.json' { 22 | const lock: PackageLock; 23 | export default lock; 24 | } 25 | -------------------------------------------------------------------------------- /src/pyodide/types/pyodide.asm.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'pyodide-internal:generated/pyodide.asm.wasm' { 2 | const pyodideWasmModule: WebAssembly.Module; 3 | export default pyodideWasmModule; 4 | } 5 | 6 | declare module 'pyodide-internal:generated/pyodide.asm' { 7 | const _createPyodideModule: (es: EmscriptenSettings) => Promise; 8 | } 9 | -------------------------------------------------------------------------------- /src/pyodide/types/python_stdlib.zip.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'pyodide-internal:generated/python_stdlib.zip' { 2 | const stdlib: Uint8Array; 3 | export default stdlib; 4 | } 5 | -------------------------------------------------------------------------------- /src/pyodide/types/setup-emscripten.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace SetupEmscripten { 2 | const getModule: () => Module; 3 | } 4 | 5 | export default SetupEmscripten; 6 | -------------------------------------------------------------------------------- /src/pyodide/types/unsafe-eval.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace UnsafeEval { 2 | const newWasmModule: (wasm: Uint8Array) => WebAssembly.Module; 3 | } 4 | 5 | export default UnsafeEval; 6 | -------------------------------------------------------------------------------- /src/rust/BUILD.bazel: -------------------------------------------------------------------------------- 1 | exports_files(["rustfmt.toml"]) 2 | -------------------------------------------------------------------------------- /src/rust/cxx-integration-test/cxx-rust-integration-test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define operatorCALL operator() 6 | 7 | namespace workerd::rust::test { 8 | 9 | using TestCallback = kj::Function; 10 | 11 | using UsizeCallback = kj::Function; 12 | 13 | } // namespace edgeworker::rust::test 14 | -------------------------------------------------------------------------------- /src/rust/cxx-integration/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_rust_crate.bzl", "rust_cxx_include", "wd_rust_crate") 2 | 3 | wd_rust_crate( 4 | name = "cxx-integration", 5 | cxx_bridge_deps = [ 6 | "@capnp-cpp//src/kj", 7 | ], 8 | cxx_bridge_src = "lib.rs", 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | "@crates_vendor//:tokio", 12 | "@crates_vendor//:tracing", 13 | ], 14 | ) 15 | 16 | rust_cxx_include( 17 | name = "cxx-include", 18 | include_prefix = "rust", 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /src/rust/cxx-integration/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod tokio; 2 | 3 | #[cxx::bridge(namespace = "workerd::rust::cxx_integration")] 4 | mod ffi { 5 | extern "Rust" { 6 | fn init(); 7 | 8 | fn trigger_panic(msg: &str); 9 | } 10 | 11 | unsafe extern "C++" { 12 | include!("workerd/rust/cxx-integration/cxx-bridge.h"); 13 | } 14 | } 15 | 16 | pub fn init() { 17 | init_tokio(None); 18 | } 19 | 20 | /// Initialize tokio runtime. 21 | /// Should not be called directly but as a part of a downstream cxx-integration init. 22 | pub fn init_tokio(worker_threads: Option) { 23 | tokio::init(worker_threads); 24 | } 25 | 26 | fn trigger_panic(msg: &str) { 27 | panic!("{}", msg) 28 | } 29 | -------------------------------------------------------------------------------- /src/rust/dns/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_rust_crate.bzl", "wd_rust_crate") 2 | 3 | wd_rust_crate( 4 | name = "dns", 5 | cxx_bridge_src = "lib.rs", 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//src/rust/cxx-integration", 9 | "@crates_vendor//:thiserror", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /src/rust/gen-compile-cache/cxx-bridge.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace workerd::rust::gen_compile_cache { 6 | ::rust::Vec compile(::rust::Str path, ::rust::Str source); 7 | } 8 | -------------------------------------------------------------------------------- /src/rust/net/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_rust_crate.bzl", "wd_rust_crate") 2 | 3 | wd_rust_crate( 4 | name = "net", 5 | cxx_bridge_src = "lib.rs", 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//src/rust/cxx-integration", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /src/rust/net/lib.rs: -------------------------------------------------------------------------------- 1 | use std::net::IpAddr; 2 | use std::str::FromStr; 3 | 4 | #[cxx::bridge(namespace = "workerd::rust::net")] 5 | mod ffi { 6 | extern "Rust" { 7 | fn canonicalize_ip(input: &str) -> String; 8 | } 9 | } 10 | 11 | #[must_use] 12 | pub fn canonicalize_ip(input: &str) -> String { 13 | IpAddr::from_str(input) 14 | .map(|ip| ip.to_string()) 15 | .unwrap_or(String::new()) 16 | } 17 | -------------------------------------------------------------------------------- /src/rust/python-parser/BUILD: -------------------------------------------------------------------------------- 1 | load("//:build/kj_test.bzl", "kj_test") 2 | load("//:build/wd_rust_crate.bzl", "rust_cxx_include", "wd_rust_crate") 3 | 4 | wd_rust_crate( 5 | name = "python-parser", 6 | cxx_bridge_src = "lib.rs", 7 | visibility = ["//visibility:public"], 8 | deps = [ 9 | "@crates_vendor//:ruff_python_ast", 10 | "@crates_vendor//:ruff_python_parser", 11 | ], 12 | ) 13 | 14 | kj_test( 15 | src = "import_parsing.c++", 16 | deps = [ 17 | ":python-parser", 18 | "//deps/rust:runtime", 19 | "//src/rust/cxx-integration", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /src/rust/rustfmt.toml: -------------------------------------------------------------------------------- 1 | group_imports = "StdExternalCrate" 2 | imports_granularity = "Item" 3 | 4 | -------------------------------------------------------------------------------- /src/workerd/README.md: -------------------------------------------------------------------------------- 1 | The subdirectories are organized as follows: 2 | 3 | * **util:** Contains random unrelated utilities that don't depend on each other or the rest of the system. 4 | * **jsg:** Contains magic template library for auto-generating FFI glue between C++ and V8 JavaScript. 5 | * **io:** Generally contains code that handles the I/O layer which allows APIs to talk to the rest of the world. Also includes basic Worker lifecycle and event delivery. 6 | * **api:** Contains implementations of publicly documented application-visible JavaScript APIs. 7 | * **server:** Contains the high-level server implementation. 8 | * **tools:** Contains additional meta-programs, notably a script for exporting API types. -------------------------------------------------------------------------------- /src/workerd/api/crypto/crc-impl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2025 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #pragma once 6 | #include 7 | 8 | // crc32-c implementation according to the spec: 9 | // https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-iscsi 10 | uint32_t crc32c(uint32_t crc, const uint8_t *data, unsigned int length); 11 | 12 | // crc64-nvme implementation according to the spec: 13 | // https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-64-nvme 14 | uint64_t crc64nvme(uint64_t crc, const uint8_t *data, unsigned int length); 15 | -------------------------------------------------------------------------------- /src/workerd/api/crypto/jwk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "impl.h" 4 | #include "keys.h" 5 | 6 | namespace workerd::api { 7 | 8 | // TODO(soon): All of the JWK conversion logic will be moved in here 9 | // soon. Currently this only covers conversion with ncrypto keys not 10 | // kj::Own held keys. 11 | 12 | SubtleCrypto::JsonWebKey toJwk( 13 | const ncrypto::EVPKeyPointer& key, KeyType keyType = KeyType::PUBLIC); 14 | 15 | ncrypto::EVPKeyPointer fromJwk( 16 | const SubtleCrypto::JsonWebKey& jwk, KeyType keyType = KeyType::PUBLIC); 17 | 18 | } // namespace workerd::api 19 | -------------------------------------------------------------------------------- /src/workerd/api/crypto/prime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace workerd::jsg { 8 | class Lock; 9 | class BufferSource; 10 | } // namespace workerd::jsg 11 | 12 | namespace workerd::api { 13 | 14 | // Generate a random prime number 15 | jsg::BufferSource randomPrime(jsg::Lock& js, 16 | uint32_t size, 17 | bool safe, 18 | kj::Maybe> add_buf, 19 | kj::Maybe> rem_buf); 20 | 21 | // Checks if the given buffer represents a prime. 22 | bool checkPrime(kj::ArrayPtr buffer, uint32_t num_checks); 23 | 24 | } // namespace workerd::api 25 | -------------------------------------------------------------------------------- /src/workerd/api/crypto/spkac.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace workerd::api { 8 | 9 | bool verifySpkac(kj::ArrayPtr input); 10 | 11 | kj::Maybe exportPublicKey(jsg::Lock& js, kj::ArrayPtr input); 12 | 13 | kj::Maybe exportChallenge(jsg::Lock& js, kj::ArrayPtr input); 14 | 15 | } // namespace workerd::api 16 | -------------------------------------------------------------------------------- /src/workerd/api/http-standard-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "http-standard-test", 6 | worker = ( 7 | modules = [ 8 | ( name = "worker", esModule = embed "http-standard-test.js" ) 9 | ], 10 | bindings = [ 11 | ( name = "SERVICE", service = "http-standard-test" ) 12 | ], 13 | compatibilityDate = "2025-02-01", 14 | compatibilityFlags = ["nodejs_compat"], 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/kv-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "kv-test", 6 | worker = ( 7 | modules = [ 8 | ( name = "worker", esModule = embed "kv-test.js" ) 9 | ], 10 | bindings = [ ( name = "KV", kvNamespace = "kv-test" ), ], 11 | compatibilityDate = "2023-07-24", 12 | # "experimental" flag is needed to test deleteBulk 13 | compatibilityFlags = ["experimental", "nodejs_compat", "service_binding_extra_handlers"], 14 | ) 15 | ), 16 | ], 17 | ); 18 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/assert-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "assert-nodejs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "assert-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/async_hooks-nodejs-test.js: -------------------------------------------------------------------------------- 1 | import async_hooks from 'node:async_hooks'; 2 | import { ok, deepStrictEqual } from 'node:assert'; 3 | 4 | export const testErrorMethodNotImplemented = { 5 | async test() { 6 | deepStrictEqual(async_hooks.executionAsyncId(), 0); 7 | deepStrictEqual(async_hooks.triggerAsyncId(), 0); 8 | deepStrictEqual(async_hooks.executionAsyncResource(), Object.create(null)); 9 | ok(async_hooks.createHook({})); 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/async_hooks-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-async_hooks-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "async_hooks-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2025-01-24", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/bound-als-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "bound-als-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "bound-als-test.js") 9 | ], 10 | compatibilityDate = "2025-05-01", 11 | compatibilityFlags = [ 12 | "nodejs_compat", 13 | "bind_asynclocalstorage_snapshot_to_request", 14 | ], 15 | bindings = [ 16 | (name = "subrequest", service = "bound-als-test"), 17 | ] 18 | ) 19 | ), 20 | ], 21 | ); 22 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/buffer-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-buffer-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "buffer-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["experimental", "nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_dh-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_dh-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_dh-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_hash-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_hash-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_hash-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_hkdf-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_hkdf-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_hkdf-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_hmac-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_hmac-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_hmac-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_pbkdf2-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_pbkdf2-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_pbkdf2-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_random-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_random-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_random-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_scrypt-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_scrypt-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_scrypt-test.js") 9 | ], 10 | compatibilityDate = "2024-06-03", 11 | compatibilityFlags = ["nodejs_compat_v2", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_spkac-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_spkac-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_spkac-test.js") 9 | ], 10 | compatibilityDate = "2024-05-03", 11 | compatibilityFlags = ["nodejs_compat_v2", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/crypto_x509-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto_x509-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto_x509-test.js") 9 | ], 10 | compatibilityDate = "2024-06-03", 11 | compatibilityFlags = ["nodejs_compat_v2"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/diagnostics-channel-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "diagnostics-channel-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "diagnostics-channel-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/dns-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-dns-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "dns-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2024-10-11", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/dh_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIBPgIBADCCARcGCSqGSIb3DQEDATCCAQgCggEBAP//////////rfhUWKK7Spqv 3 | 3FYgJz088di5xYPOLTaVqeE2QRRkM/vMk53OJJs++X0v42NjDHXY9oGyAq7EYXrT 4 | 3x7V1f1lYSQz9R9fBm7QhWNlVT3tGvO1VxNef1fJNZhPDHDg5ot34qaJ2vPv6HId 5 | 8VihNq3nNTCsyk9IOnl6vAqxgrMk+2HRCKlLssjj+7lq2rdg1/RoHU9Co945TfSu 6 | Vu3nY3K7GQsHp8juCm1wngL84c334uzANATNKDQvYZFy/pzphYP/jk8SMu7ygYPD 7 | /jsbTG+tczu1/LwuwiAFxY7xg30Wg7LG80omwbLv+ohrQjhhKFyX//////////8C 8 | AQIEHgIcKNGyhQRxIhVXoyktdymwbN6MgXv85vPax+8eqQ== 9 | -----END PRIVATE KEY----- 10 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_p256_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgDxBsPQPIgMuMyQbx 3 | zbb9toew6Ev6e9O6ZhpxLNgmAEqhRANCAARfSYxhH+6V5lIg+M3O0iQBLf+53kuE 4 | 2luIgWnp81/Ya1Gybj8tl4tJVu1GEwcTyt8hoA7vRACmCHnI5B1+bNpS 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_p256_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEX0mMYR/uleZSIPjNztIkAS3/ud5L 3 | hNpbiIFp6fNf2GtRsm4/LZeLSVbtRhMHE8rfIaAO70QApgh5yOQdfmzaUg== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_p384_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDB3B+4e4C1OUxGftkEI 3 | Gb/SCulzUP/iE940CB6+B6WWO4LT76T8sMWiwOAGUsuZmyKhZANiAASE43efMYmC 4 | /7Tx90elDGBEkVnOUr4ZkMZrl/cqe8zfVy++MmayPhR46Ah3LesMCNV+J0eG15w0 5 | IYJ8uqasuMN6drU1LNbNYfW7+hR0woajldJpvHMPv7wlnGOlzyxH1yU= 6 | -----END PRIVATE KEY----- 7 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_p384_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEhON3nzGJgv+08fdHpQxgRJFZzlK+GZDG 3 | a5f3KnvM31cvvjJmsj4UeOgIdy3rDAjVfidHhtecNCGCfLqmrLjDena1NSzWzWH1 4 | u/oUdMKGo5XSabxzD7+8JZxjpc8sR9cl 5 | -----END PUBLIC KEY----- 6 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_p521_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIAEghuafcab9jXW4gO 3 | QLeDaKOlHEiskQFjiL8klijk6i6DNOXcFfaJ9GW48kxpodw16ttAf9Z1WQstfzpK 4 | GUetHImhgYkDgYYABAGixYI8Gbc5zNze6rH2/OmsFV3unOnY1GDqG9RTfpJZXpL9 5 | ChF1dG8HA4zxkM+X+jMSwm4THh0Wr1Euj9dK7E7QZwHd35XsQXgH13Hjc0QR9dvJ 6 | BWzlg+luNTY8CkaqiBdur5oFv/AjpXRimYxZDkhAEsTwXLwNohSUVMkN8IQtNI9D 7 | aQ== 8 | -----END PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_p521_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBosWCPBm3Oczc3uqx9vzprBVd7pzp 3 | 2NRg6hvUU36SWV6S/QoRdXRvBwOM8ZDPl/ozEsJuEx4dFq9RLo/XSuxO0GcB3d+V 4 | 7EF4B9dx43NEEfXbyQVs5YPpbjU2PApGqogXbq+aBb/wI6V0YpmMWQ5IQBLE8Fy8 5 | DaIUlFTJDfCELTSPQ2k= 6 | -----END PUBLIC KEY----- 7 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_secp256k1_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgc34ocwTwpFa9NZZh3l88 3 | qXyrkoYSxvC0FEsU5v1v4IOhRANCAARw7OEVKlbGFqUJtY10/Yf/JSR0LzUL1PZ1 4 | 4Ol/ErujAPgNwwGU5PSD6aTfn9NycnYB2hby9XwB2qF3+El+DV8q 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ec_secp256k1_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEcOzhFSpWxhalCbWNdP2H/yUkdC81C9T2 3 | deDpfxK7owD4DcMBlOT0g+mk35/TcnJ2AdoW8vV8Adqhd/hJfg1fKg== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ed25519_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MC4CAQAwBQYDK2VwBCIEIMFSujN0jIUIdzSvuxka0lfgVVkMdRTuaVvIYUHrvzXQ 3 | -----END PRIVATE KEY----- 4 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ed25519_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MCowBQYDK2VwAyEAK1wIouqnuiA04b3WrMa+xKIKIpfHetNZRv3h9fBf768= 3 | -----END PUBLIC KEY----- 4 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ed448_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MEcCAQAwBQYDK2VxBDsEOdOtCnu9bDdBqSHNNZ5xoDA5KdLBTUNPcKFaOADNX32s 3 | dfpo52pCtPqfku/l3/OfUHsF43EfZsaaWA== 4 | -----END PRIVATE KEY----- 5 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/ed448_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MEMwBQYDK2VxAzoAoX/ee5+jlcU53+BbGRsGIzly0V+SZtJ/oGXY0udf84q2hTW2 3 | RdstLktvwpkVJOoNb7oDgc2V5ZUA 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_pss_public_2048.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIDALBgkqhkiG9w0BAQoDggEPADCCAQoCggEBAMuDjHUvOD5YCOQkS23W7nfU 3 | bu76axa9mDTVJnU+w92IAKYr/Ao8yly4lQ52zBE/pcJrWoPxHGbMVQiqL7Lt9KWA 4 | Ega4hzojFWLovfmWiaEPciOpToxtUW7lASVzUoxwScagapnIGTm9ZnUa/3l86QDF 5 | id4X7i6I1Nvs1Eid/673qXqXCxRtqvZwNPjybJCez54dy9MnZ791N4XbjJ+TlX5v 6 | ycdRT8maQ9fOLSX3/jfjGN7N4SHH7jpy/T5eETxnmkwuE9aOOtDWhumxu3NloYOj 7 | TmlYGhSGojW600zQqVY3k8mpbE12JUEN4Yio7LdEO6XxRJCQ6PKoqi2ndTLJefcC 8 | AwEAAQ== 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_pss_public_2048_sha1_sha1_20.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQowAAOCAQ8AMIIBCgKCAQEAqXbrc7DxUNddNKLkeWgM 3 | GK8vGgLRtHPs1/VKjVxgqUQ1szz6Vx1GUgdQZk0y+BIStrZAH25WDas0bggGJSh2 4 | xaRS7NsyxKK36dFrBTT2gRxPSR6SyDOKF8TwlMqWeyQJ+emWKJ2AmfCJefEsw/Wq 5 | BeNUUxJqXMd15C9kUGtNtkYknHGGSsf8s7JFFAHU7072Mrox9TJL7H1T/jbOW0S+ 6 | iFaqMBXd8b+nLb30DMc9K5bYEwvsDptwhbZ/hut8uj/2dFNg0XWnLDZDejxRlwCA 7 | dJErys7PIFaHBAYksDJHE/yg90evD2NfG9mrqmhnJvIAPoGlSd+igFuHTgI22PmI 8 | rQIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_pss_public_2048_sha256_sha256_16.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBUjA9BgkqhkiG9w0BAQowMKANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3DQEB 3 | CDALBglghkgBZQMEAgGiAwIBEAOCAQ8AMIIBCgKCAQEA36jTOAvkLQ+94iC6jpKn 4 | 1fIWtztfY6V/FLoyJNWe9m227sBM4dPrAcNHQ9DfAoJF53jzhBHequxzZm8gjaka 5 | QyujQ72gjA1oBGg/z5R5EZ7byofNSF0jAuYpo0XznGSBPxp8O4fLWp2m9J++fjg7 6 | yya5hFlBtqu/SJtZljMe0qaHfjaelxGPuyO5wFFFor69+WMeQ3ssWPK8RRqbC7Rr 7 | IuyTUDuGh8ngaY/Lc9BYb9t7j8sBNpxpjx355F1m603Bxm82AYBG3kh/SlJEcHM6 8 | g1zTj4bX2hBxBU5tDKHigpyXtVTo0ssHr++3VdSmX6VYdyodGUUCHvWDlSYY+JTM 9 | dwIDAQAB 10 | -----END PUBLIC KEY----- 11 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_pss_public_2048_sha512_sha256_20.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBTTA4BgkqhkiG9w0BAQowK6ANMAsGCWCGSAFlAwQCA6EaMBgGCSqGSIb3DQEB 3 | CDALBglghkgBZQMEAgEDggEPADCCAQoCggEBALzPTYDAg6suXao+VGtnGXHOM1a/ 4 | nwhd+G2Z+tzgXmBvEUySjN49+pTv8mprXw3LQ4W/O2+OQkuoqRK/CeeyPVheeUzZ 5 | 4LJ+hjaV4MAHtHhV1JyqJ7qpxhAu8fK975AIPfTwSoQLRXOaE2mmQwBSjM3OXSAv 6 | ydGPpMYaowjzSNMnUIGZiga5mIzPXL2zmIEUC9dBq1niflx5NhN93p3WhfuHcI4M 7 | q8yJ7f5ejk5Igi/BefSf4bZNRj67vQU+sOcjkv7x+quhQ+ros1C1c58rXZR44J61 8 | WhyZrKlY62EGvTgGY/Rga03pQVr0PW+vhQR1BRwafB0qfNpVgmU4T63Gf0MCAwEA 9 | AQ== 10 | -----END PUBLIC KEY----- 11 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt9xYiIonscC3vz/A2ceR 3 | 7KhZZlDu/5bye53nCVTcKnWd2seY6UAdKersX6njr83Dd5OVe1BW/wJvp5EjWTAG 4 | YbFswlNmeD44edEGM939B6Lq+/8iBkrTi8mGN4YCytivE24YI0D4XZMPfkLSpab2 5 | y/Hy4DjQKBq1ThZ0UBnK+9IhX37Ju/ZoGYSlTIGIhzyaiYBh7wrZBoPczIEu6et/ 6 | kN2VnnbRUtkYTF97ggcv5h+hDpUQjQW0ZgOMcTc8n+RkGpIt0/iM/bTjI3Tz/gsF 7 | di6hHcpZgbopPL630296iByyigQCPJVzdusFrQN5DeC+zT/nGypQkZanLb4ZspSx 8 | 9QIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_public_2048.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArk4OqxBqU5/k0FoUDU7C 3 | pZpjz6YJEXUpyqeJmFRVZPMUv/Rc7U4seLY+Qp6k26T/wlQ2WJWuyY+VJcbQNWLv 4 | jJWks5HWknwDuVs6sjuTM8CfHWn1960JkK5Ec2TjRhCQ1KJy+uc3GJLtWb4rWVgT 5 | bbaaC5fiR1/GeuJ8JH1Q50lB3mDsNGIk1U5jhNaYY82hYvlbErf6Ft5njHK0BOM5 6 | OTvQ6BBv7c363WNG7tYlNw1J40dup9OQPo5JmXN/h+sRbdgG8iUxrkRibuGv7loh 7 | 52QQgq2snznuRMdKidRfUZjCDGgwbgK23Q7n8VZ9Y10j8PIvPTLJ83PX4lOEA37J 8 | lwIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/rsa_public_b.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyb1grrN+29fxeeEbTaSE 3 | ja6TKDTpT/WXnqrFCS+h7IYcnDoAVwcsPU5FZeUPvLKMzi9NHSJ34LQCurqHgH8X 4 | +cw0YT3gdYS/7qoQiXs+zKv615NcttD3xlQLceY+NwznoPXyyZwOeZqyU5Hiqbrq 5 | u6hdr6gQYogMNLn2NxBW2pGegd6+ZGMCX3+/BtMP/6tXmttYjY+yhN2SrGz5cKhW 6 | pcHiC6X+B7uCKoKZy+t2jUxYVKUwWr1ZuM8kpSnuVCcv1OoMGEimEHA7v/eaF/y+ 7 | z/VdQ4Y88GhTnVN4KbtgZ+o9PohjxLFU62VeTALixU5mPQKSgSICKfjev0FUUurF 8 | 6wIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/x25519_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MC4CAQAwBQYDK2VuBCIEIJi/yFpueUawC1BkXyWM8ONIBGFjL7UZHrD/Zo/KPDpn 3 | -----END PRIVATE KEY----- 4 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/x25519_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MCowBQYDK2VuAyEAaSb8Q+RndwfNnPeOYGYPDUN3uhAPnMLzXyfi+mqfhig= 3 | -----END PUBLIC KEY----- 4 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/x448_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MEYCAQAwBQYDK2VvBDoEOLTDbazv6vHZWOmODQ3kk8TUOQgApB4j75rpInT5zSLl 3 | /xJHK8ixF7f+4uo+mGTCrK1sktI5UmCZ 4 | -----END PRIVATE KEY----- 5 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fixtures/x448_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MEIwBQYDK2VvAzkAioHSHVpTs6hMvghosEJDIR7ceFiE3+Xccxati64oOVJ7NWjf 3 | ozE7ae31PXIUFq6cVYgvSKsDFPA= 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/fs-access-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "fs-access-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "fs-access-test.js") 9 | ], 10 | compatibilityDate = "2025-05-01", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/http-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "http-nodejs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "http-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2025-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/legacy_url-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "legacy_url-nodejs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "legacy_url-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/mimetype-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "mimetype-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "mimetype-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/node-compat-v2-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "node-compat-v2-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "node-compat-v2-test.js"), 9 | (name = "node:fs", esModule = "export default 1"), 10 | (name = "node:path", esModule = "export default 2"), 11 | ], 12 | compatibilityDate = "2024-05-01", 13 | compatibilityFlags = ["nodejs_compat_v2"] 14 | ) 15 | ), 16 | ], 17 | ); 18 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/path-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "path-nodejs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "path-test.js") 9 | ], 10 | compatibilityDate = "2024-10-11", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/querystring-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-querystring-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "querystring-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2024-10-11", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/streams-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "streams-nodejs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "streams-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2025-01-09", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ( name = "internet", network = ( allow = ["private"] ) ), 15 | ], 16 | ); 17 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/streams-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "streams-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "streams-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/string-decoder-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "string-decoder-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "string-decoder-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["experimental", "nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/sys-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-sys-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "sys-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2024-09-23", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/timers-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-timers-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "timers-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2025-01-09", 11 | compatibilityFlags = ["nodejs_compat", "no_nodejs_compat_v2"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/url-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-url-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "url-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2024-10-11", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/node/tests/util-nodejs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "nodejs-util-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "util-nodejs-test.js") 9 | ], 10 | compatibilityDate = "2025-04-01", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/pyodide/setup-emscripten.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace workerd::api::pyodide { 6 | struct EmscriptenRuntime { 7 | jsg::JsRef contextToken; 8 | jsg::JsRef emscriptenRuntime; 9 | static EmscriptenRuntime initialize(jsg::Lock& js, bool isWorkerd, jsg::Bundle::Reader bundle); 10 | }; 11 | } // namespace workerd::api::pyodide 12 | -------------------------------------------------------------------------------- /src/workerd/api/queue-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "queue-test", 6 | worker = ( 7 | modules = [ 8 | ( name = "worker", esModule = embed "queue-test.js" ) 9 | ], 10 | bindings = [ 11 | ( name = "QUEUE", queue = "queue-test" ), 12 | ( name = "SERVICE", service = "queue-test" ), 13 | ], 14 | compatibilityDate = "2023-07-24", 15 | compatibilityFlags = ["nodejs_compat", "service_binding_extra_handlers"], 16 | ) 17 | ), 18 | ], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/api/r2-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "r2-test", 6 | worker = ( 7 | modules = [ 8 | ( name = "worker", esModule = embed "r2-test.js" ) 9 | ], 10 | bindings = [ 11 | ( name = "BUCKET", r2Bucket = "r2-test" ), 12 | ( name = "SERVICE", service = "r2-test" ), 13 | ], 14 | compatibilityDate = "2023-07-24", 15 | compatibilityFlags = ["nodejs_compat", "service_binding_extra_handlers"], 16 | ) 17 | ), 18 | ], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/api/rtti-test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import assert from 'node:assert'; 6 | import rtti from 'workerd:rtti'; 7 | 8 | export default { 9 | async test(ctrl, env, ctx) { 10 | const buffer = rtti.exportTypes('2023-05-18', ['nodejs_compat']); 11 | assert(buffer.byteLength > 0); 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /src/workerd/api/rtti-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "rtti-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "rtti-test.js") 9 | ], 10 | compatibilityDate = "2023-05-18", 11 | compatibilityFlags = ["nodejs_compat", "rtti_api"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/scheduled.c++: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #include "scheduled.h" 6 | 7 | #include 8 | 9 | namespace workerd::api { 10 | 11 | ScheduledEvent::ScheduledEvent(double scheduledTime, kj::StringPtr cron) 12 | : ExtendableEvent("scheduled"), 13 | scheduledTime(scheduledTime), 14 | cron(kj::str(cron)) {} 15 | 16 | void ScheduledEvent::noRetry() { 17 | IoContext::current().setNoRetryScheduled(); 18 | } 19 | 20 | } // namespace workerd::api 21 | -------------------------------------------------------------------------------- /src/workerd/api/self-logger-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | (name = "self-logger", worker = .selfLoggerWorker), 6 | ], 7 | ); 8 | 9 | const selfLoggerWorker :Workerd.Worker = ( 10 | modules = [ 11 | (name = "worker", esModule = embed "self-logger-test.js") 12 | ], 13 | bindings = [ 14 | ( name = "SERVICE", service = "self-logger" ), 15 | ], 16 | compatibilityDate = "2024-10-14", 17 | compatibilityFlags = ["nodejs_compat"], 18 | tails = ["self-logger"], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/api/streams/identitytransformstream-backpressure-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "identitytransformstream-backpressure-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "identitytransformstream-backpressure-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tail-worker-test-dummy.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | export default { 5 | // https://developers.cloudflare.com/workers/observability/logs/tail-workers/ 6 | tail(event, env, ctx) { 7 | return (event) => {}; 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /src/workerd/api/tests/abort-internal-streams-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "abort-internal-streams-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "abort-internal-streams-test.js") 9 | ], 10 | compatibilityDate = "2024-07-01", 11 | compatibilityFlags = ["nodejs_compat_v2", "internal_writable_stream_abort_clears_queue"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/abortable-fetch-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "abortable-fetch-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "abortable-fetch-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | bindings = [ 13 | (name = "subrequest", service = "abortable-fetch-test") 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/abortsignal-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "abortsignal-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "abortsignal-test.js") 9 | ], 10 | compatibilityDate = "2025-01-01", 11 | compatibilityFlags = ["nodejs_compat", "enable_abortsignal_rpc", "experimental"], 12 | bindings = [ 13 | (name = "RpcRemoteEnd", service = (name = "abortsignal-test", entrypoint = "RpcRemoteEnd")), 14 | ] 15 | ) 16 | ), 17 | ], 18 | v8Flags = ["--expose-gc"] 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/api/tests/als-only-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "als-only-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "als-only-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_als"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/als-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "als-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "als-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/blob-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "blob-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "blob-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | bindings = [ 13 | (name = "request-blob", service = "blob-test") 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/blob2-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "blob2-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "blob2-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "blob_standard_mime_type"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/commonjs-module-test.js: -------------------------------------------------------------------------------- 1 | import { foo, bar, default as baz } from 'foo'; 2 | import * as fooModule from 'foo'; 3 | import { strictEqual } from 'node:assert'; 4 | 5 | export const test = { 6 | test() { 7 | strictEqual(fooModule.default, baz); 8 | strictEqual(fooModule.foo, foo); 9 | strictEqual(fooModule.bar, undefined); 10 | strictEqual(foo, 1); 11 | strictEqual(bar, undefined); 12 | strictEqual(baz.foo, foo); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /src/workerd/api/tests/commonjs-module-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "commonjs-module-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "commonjs-module-test.js"), 9 | (name = "foo", 10 | commonJsModule = "exports.foo = 1", 11 | namedExports = ["foo", "bar"]) 12 | ], 13 | compatibilityDate = "2023-01-15", 14 | compatibilityFlags = ["nodejs_compat"], 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/compat-flags-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "compat-flags-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "compat-flags-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat_v2"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/cross-context-promise-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "cross-context-promise-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "cross-context-promise-test.js") 9 | ], 10 | compatibilityDate = "2024-07-01", 11 | compatibilityFlags = [ 12 | "nodejs_compat_v2", 13 | "handle_cross_request_promise_resolution", 14 | ], 15 | bindings = [ 16 | (name = "subrequest", service = "cross-context-promise-test") 17 | ] 18 | ) 19 | ), 20 | ], 21 | ); 22 | -------------------------------------------------------------------------------- /src/workerd/api/tests/crypto-extras-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto-extras-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto-extras-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/crypto-impl-asymmetric-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto-impl-asymmetric-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto-impl-asymmetric-test.js") 9 | ], 10 | compatibilityDate = "2023-05-18", 11 | compatibilityFlags = ["experimental", "nodejs_compat", "crypto_preserve_public_exponent"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/crypto-streams-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "crypto-streams-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "crypto-streams-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/data-url-fetch-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "data-url-fetch-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "data-url-fetch-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/encoding-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "encoding-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "encoding-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/error-in-error-event-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "error-in-error-event-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "error-in-error-event-test.js") 9 | ], 10 | compatibilityDate = "2024-09-15", 11 | compatibilityFlags = ["nodejs_compat_v2"], 12 | bindings = [ 13 | (name = "subrequest", service = "error-in-error-event-test") 14 | ], 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/events-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "events-nodejs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "events-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/eventsource-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "eventsource-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "eventsource-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"], 12 | bindings = [ 13 | (name = "subrequest", service = "eventsource-test") 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/fetch-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "fetch-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "fetch-test.js") 9 | ], 10 | compatibilityDate = "2024-10-01", 11 | compatibilityFlags = ["nodejs_compat", "upper_case_all_http_methods"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/form-data-legacy-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTestsLegacy :Workerd.Config = ( 4 | services = [ 5 | ( name = "form-data-legacy-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "form-data-legacy-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = [ 12 | "nodejs_compat", 13 | "formdata_parser_converts_files_to_strings" 14 | ], 15 | ) 16 | ), 17 | ], 18 | ); 19 | 20 | -------------------------------------------------------------------------------- /src/workerd/api/tests/form-data-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "form-data-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "form-data-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = [ 12 | "nodejs_compat" 13 | ], 14 | ) 15 | ), 16 | ], 17 | ); 18 | -------------------------------------------------------------------------------- /src/workerd/api/tests/global-scope-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "global-scope-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "global-scope-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | # "experimental" is for ctx.exports 12 | compatibilityFlags = ["nodejs_compat", "set_tostring_tag", "experimental"] 13 | ) 14 | ), 15 | ], 16 | ); 17 | -------------------------------------------------------------------------------- /src/workerd/api/tests/htmlrewriter-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "htmlrewriter-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "htmlrewriter-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/module-test.js: -------------------------------------------------------------------------------- 1 | import * as assert from 'a/b/c'; 2 | import * as assert3 from 'node:assert'; 3 | 4 | export const basics = { 5 | async test() { 6 | const assert2 = await import('a/b/c'); 7 | if (assert !== assert2 && assert !== assert3) { 8 | throw new Error('bad things happened'); 9 | } 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/workerd/api/tests/module-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "module-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "module-test.js"), 9 | (name = "a/b/c", 10 | esModule = "import * as assert from 'node:assert'; await import('node:buffer'); export default assert;"), 11 | ], 12 | compatibilityDate = "2023-01-15", 13 | compatibilityFlags = ["nodejs_compat"] 14 | ) 15 | ), 16 | ], 17 | ); 18 | -------------------------------------------------------------------------------- /src/workerd/api/tests/navigator-beacon-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const worker :Workerd.Worker = ( 4 | modules = [ 5 | (name = "worker", esModule = embed "navigator-beacon-test.js") 6 | ], 7 | compatibilityDate = "2023-01-15", 8 | compatibilityFlags = ["nodejs_compat"], 9 | ); 10 | 11 | const unitTests :Workerd.Config = ( 12 | services = [ 13 | ( name = "navigator-beacon-test", worker = .worker ), 14 | ( name = "internet", worker = .worker ) 15 | ], 16 | ); 17 | -------------------------------------------------------------------------------- /src/workerd/api/tests/navigator-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "navigator-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "navigator-test.js") 9 | ], 10 | compatibilityDate = "2025-01-15", 11 | compatibilityFlags = ["nodejs_compat", "enable_navigator_language"], 12 | ), 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/no-to-string-tag-test.js: -------------------------------------------------------------------------------- 1 | import { strictEqual } from 'node:assert'; 2 | 3 | export default { 4 | test() { 5 | const h = new Headers(); 6 | strictEqual(h[Symbol.toStringTag], undefined); 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /src/workerd/api/tests/no-to-string-tag-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "no-to-string-tag-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "no-to-string-tag-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"] 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/reporterror-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "reporterror-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "reporterror-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/response-json.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "response-json", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "response-json.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/api/tests/scheduler-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "scheduler-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "scheduler-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat"], 12 | bindings = [ 13 | (name = "subrequest", service = "scheduler-test") 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/streams-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | v8Flags = ["--expose-gc"], 5 | services = [ 6 | ( name = "streams-test", 7 | worker = ( 8 | modules = [ 9 | (name = "worker", esModule = embed "streams-test.js") 10 | ], 11 | compatibilityDate = "2023-01-15", 12 | compatibilityFlags = ["nodejs_compat", "internal_stream_byob_return_view"], 13 | bindings = [ 14 | (name = "subrequest", service = "streams-test") 15 | ] 16 | ) 17 | ), 18 | ], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/api/tests/test.wasm: -------------------------------------------------------------------------------- 1 | asm`add 2 |  j -------------------------------------------------------------------------------- /src/workerd/api/tests/unsafe-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "unsafe-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "unsafe-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = ["nodejs_compat", "experimental"], 12 | bindings = [ 13 | (name = "unsafe", unsafeEval = void ) 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/url-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "url-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "url-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | compatibilityFlags = [ 12 | "nodejs_compat", 13 | "urlsearchparams_delete_has_value_arg", 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/webfs-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "webfs-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "webfs-test.js") 9 | ], 10 | compatibilityDate = "2025-05-01", 11 | compatibilityFlags = [ 12 | "nodejs_compat", 13 | "enable_web_file_system", 14 | "experimental", 15 | ] 16 | ) 17 | ), 18 | ], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/api/tests/websocket-client-error-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const config :Workerd.Config = ( 4 | services = [ 5 | (name = "main", worker = .mainWorker), 6 | (name = "internet", network = (allow = ["private"])), 7 | ], 8 | ); 9 | 10 | const mainWorker :Workerd.Worker = ( 11 | compatibilityDate = "2025-04-11", 12 | modules = [ 13 | (name = "worker", esModule = embed "websocket-client-error-test.js"), 14 | ], 15 | bindings = [ 16 | (name = "BIG_MESSAGE_SERVER_PORT", fromEnvironment = "BIG_MESSAGE_SERVER_PORT"), 17 | ] 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/api/tests/worker-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "worker-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "worker-test.js"), 9 | (name = "module-does-eval", esModule = "export default eval('1+1')"), 10 | (name = "another-module-does-eval", esModule = "export default eval('2+2')"), 11 | ], 12 | compatibilityDate = "2025-05-13", 13 | compatibilityFlags = [ 14 | "nodejs_compat", 15 | "allow_eval_during_startup", 16 | ] 17 | ) 18 | ), 19 | ], 20 | ); 21 | -------------------------------------------------------------------------------- /src/workerd/api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": ["esnext", "webworker"], 5 | "strict": true, 6 | "moduleResolution": "node", 7 | "esModuleInterop": true, 8 | "sourceMap": true, 9 | "paths": { 10 | "@workerd/*": ["../../bazel-bin/src/workerd/*"] 11 | }, 12 | "composite": true, 13 | "declaration": true, 14 | "skipLibCheck": true, 15 | "allowJs": true 16 | }, 17 | "include": ["**/*.ts"], 18 | "exclude": ["wpt/**"] 19 | } 20 | -------------------------------------------------------------------------------- /src/workerd/io/features.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace workerd { 11 | 12 | struct FeatureFlags { 13 | FeatureFlags() = delete; 14 | 15 | // Get the feature flags that are relevant for the current jsg::Lock or 16 | // throw if we are not currently executing JavaScript. 17 | static CompatibilityFlags::Reader get(jsg::Lock&); 18 | }; 19 | 20 | } // namespace workerd 21 | -------------------------------------------------------------------------------- /src/workerd/io/io-context-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "io-context-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "io-context-test.js") 9 | ], 10 | compatibilityDate = "2025-05-01", 11 | compatibilityFlags = [ 12 | "nodejs_compat", # for assert 13 | "experimental", # for ctx.exports 14 | ], 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/io/io-util.c++: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #include "io-util.h" 6 | 7 | #include "io-context.h" 8 | 9 | #include 10 | 11 | namespace workerd { 12 | 13 | double dateNow() { 14 | if (IoContext::hasCurrent()) { 15 | auto& ioContext = IoContext::current(); 16 | return (ioContext.now() - kj::UNIX_EPOCH) / kj::MILLISECONDS; 17 | } 18 | 19 | return 0.0; 20 | } 21 | 22 | } // namespace workerd 23 | -------------------------------------------------------------------------------- /src/workerd/io/io-util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #pragma once 6 | 7 | namespace workerd { 8 | 9 | // Returns exactly what Date.now() would return. 10 | double dateNow(); 11 | 12 | } // namespace workerd 13 | -------------------------------------------------------------------------------- /src/workerd/io/supported-compatibility-date.txt: -------------------------------------------------------------------------------- 1 | 2025-06-03 2 | -------------------------------------------------------------------------------- /src/workerd/jsg/resource-test-bootstrap.js: -------------------------------------------------------------------------------- 1 | export function bootstrapFunction() { 2 | return 'THIS_IS_BOOTSTRAP_FUNCTION'; 3 | } 4 | 5 | export class BootstrapClass { 6 | run() { 7 | return 'THIS_IS_BOOTSTRAP_CLASS'; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/workerd/jsg/resource-test-builtin.js: -------------------------------------------------------------------------------- 1 | export function builtinFunction() { 2 | return 'THIS_IS_BUILTIN_FUNCTION'; 3 | } 4 | -------------------------------------------------------------------------------- /src/workerd/jsg/resource-test.capnp: -------------------------------------------------------------------------------- 1 | @0x92df13ba26adb5fe; 2 | 3 | using Modules = import "/workerd/jsg/modules.capnp"; 4 | 5 | const builtinBundle :Modules.Bundle = ( 6 | modules = [ 7 | (name = "test:resource-test-builtin", src = embed "resource-test-builtin.js", type = builtin) 8 | ]); 9 | 10 | 11 | const bootstrapBundle :Modules.Bundle = ( 12 | modules = [ 13 | (name = "test:resource-test-bootstrap", src = embed "resource-test-bootstrap.js", type = internal) 14 | ]); 15 | -------------------------------------------------------------------------------- /src/workerd/jsg/rtti-test.capnp: -------------------------------------------------------------------------------- 1 | @0xfe92df13ba26adb5; 2 | 3 | using Modules = import "/workerd/jsg/modules.capnp"; 4 | 5 | const testBundle :Modules.Bundle = ( 6 | modules = [ 7 | (name = "testBundle:internal", src = "export const foo = 'foo';", type = internal, tsDeclaration="foo: string") 8 | ]); 9 | -------------------------------------------------------------------------------- /src/workerd/jsg/v8-platform-wrapper.c++: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #include "v8-platform-wrapper.h" 6 | 7 | #include "jsg.h" 8 | 9 | #include 10 | 11 | namespace workerd::jsg { 12 | 13 | V8PlatformWrapper::JobTaskWrapper::JobTaskWrapper(std::unique_ptr inner) 14 | : inner(kj::mv(inner)) {} 15 | 16 | void V8PlatformWrapper::JobTaskWrapper::Run(v8::JobDelegate* delegate) { 17 | runInV8Stack([&](jsg::V8StackScope& stackScope) { inner->Run(delegate); }); 18 | } 19 | 20 | } // namespace workerd::jsg 21 | -------------------------------------------------------------------------------- /src/workerd/server/tests/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@aspect_rules_js//js:defs.bzl", "js_library") 2 | 3 | js_library( 4 | name = "server-harness_js_lib", 5 | srcs = ["server-harness.mjs"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /src/workerd/server/tests/compile-tests/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_shell//shell:sh_test.bzl", "sh_test") 2 | 3 | sh_test( 4 | name = "helloworld_compile_test", 5 | size = "medium", 6 | srcs = ["compile-test.sh"], 7 | args = [ 8 | "$(location //src/workerd/server:workerd)", 9 | "$(location //samples:helloworld/config.capnp)", 10 | "$(location compile-helloworld-test.ok)", 11 | ], 12 | data = [ 13 | "compile-helloworld-test.ok", 14 | "//samples:helloworld/config.capnp", 15 | "//samples:helloworld/worker.js", 16 | "//src/workerd/server:workerd", 17 | ], 18 | tags = ["no-qemu"], 19 | ) 20 | -------------------------------------------------------------------------------- /src/workerd/server/tests/compile-tests/compile-helloworld-test.ok: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /src/workerd/server/tests/extensions/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | 3 | wd_test( 4 | src = "extensions-test.wd-test", 5 | data = glob([ 6 | "*.js", 7 | "*.capnp", 8 | ]), 9 | ) 10 | -------------------------------------------------------------------------------- /src/workerd/server/tests/extensions/binding.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export function wrap(env) { 6 | if (!env.secret) { 7 | throw new Error('secret internal binding is not specified'); 8 | } 9 | 10 | return { 11 | tryOpen(key) { 12 | return key === env.secret; 13 | }, 14 | }; 15 | } 16 | 17 | export default wrap; 18 | -------------------------------------------------------------------------------- /src/workerd/server/tests/extensions/extension.capnp: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const extension :Workerd.Extension = ( 4 | modules = [ 5 | ( name = "test:module", esModule = embed "module.js" ), 6 | ( name = "test:binding", esModule = embed "binding.js", internal = true ), 7 | ( name = "test-internal:internal-module", esModule = embed "internal-module.js", internal = true ), 8 | ] 9 | ); 10 | -------------------------------------------------------------------------------- /src/workerd/server/tests/extensions/internal-module.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export default { 6 | caveKey: '0p3n s3sam3', 7 | }; 8 | -------------------------------------------------------------------------------- /src/workerd/server/tests/extensions/module.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import secret from 'test-internal:internal-module'; 6 | 7 | export function openDoor(key) { 8 | if (key != secret.caveKey) throw new Error('Wrong key: ' + key); 9 | return true; 10 | } 11 | -------------------------------------------------------------------------------- /src/workerd/server/tests/inspector/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@aspect_rules_js//js:defs.bzl", "js_test") 2 | 3 | js_test( 4 | name = "inspector-test", 5 | size = "large", 6 | data = [ 7 | ":config.capnp", 8 | ":index.mjs", 9 | "//:node_modules/chrome-remote-interface", 10 | "//src/workerd/server:workerd", 11 | "//src/workerd/server/tests:server-harness_js_lib", 12 | ], 13 | entry_point = "driver.mjs", 14 | env = { 15 | "WORKERD_BINARY": "$(rootpath //src/workerd/server:workerd)", 16 | "WORKERD_CONFIG": "$(rootpath :config.capnp)", 17 | }, 18 | tags = ["js-test"], 19 | ) 20 | -------------------------------------------------------------------------------- /src/workerd/server/tests/inspector/config.capnp: -------------------------------------------------------------------------------- 1 | # config.capnp 2 | using Workerd = import "/workerd/workerd.capnp"; 3 | 4 | const config :Workerd.Config = ( 5 | services = [ 6 | ( name = "main", worker = .worker ), 7 | ], 8 | sockets = [ 9 | ( name = "http", address = "*:0", http = (), service = "main" ), 10 | ] 11 | ); 12 | 13 | const worker :Workerd.Worker = ( 14 | modules = [ 15 | ( name = "./index.mjs", esModule = embed "index.mjs" ) 16 | ], 17 | compatibilityDate = "2024-01-01", 18 | compatibilityFlags = ["nodejs_compat"], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/asgi-sse/asgi-sse.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "python-asgi-sse", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py"), 9 | ], 10 | bindings = [ 11 | ( name = "SELF", service = "python-asgi-sse" ), 12 | ], 13 | compatibilityDate = "2024-10-01", 14 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 15 | ) 16 | ) 17 | ], 18 | ); -------------------------------------------------------------------------------- /src/workerd/server/tests/python/asgi/asgi.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "python-asgi", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py"), 9 | ], 10 | bindings = [ 11 | ( name = "SELF", service = "python-asgi" ), 12 | ], 13 | compatibilityDate = "2024-10-01", 14 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 15 | ) 16 | ) 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/dont-snapshot-pyodide/dont-snapshot-pyodide.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "dont-snapshot-pyodide", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py"), 9 | (name = "numpy", pythonRequirement = "") 10 | ], 11 | compatibilityDate = "2024-01-15", 12 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 13 | ) 14 | ), 15 | ], 16 | ); 17 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/env-param/env.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "python-hello", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py") 9 | ], 10 | bindings = [ 11 | ( 12 | name = "secret", 13 | text = "thisisasecret" 14 | ), 15 | ], 16 | compatibilityDate = "2024-01-15", 17 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 18 | ) 19 | ), 20 | ], 21 | ); 22 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/env-param/worker.py: -------------------------------------------------------------------------------- 1 | def test(ctx, env): 2 | assert hasattr(env, "secret") 3 | assert env.secret == "thisisasecret" 4 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/filter-non-py-files/worker.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/hello/hello.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "python-hello", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py") 9 | ], 10 | compatibilityDate = "2024-01-15", 11 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/hello/worker.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | from js import console 3 | from js.WebAssembly import Suspending 4 | 5 | Suspending # noqa: B018 6 | 7 | # This just tests that nothing raises when we run this. It isn't great though 8 | # because we don't test whether we printed anything. 9 | # TODO: update this to test that something happened 10 | print("Does this work?") 11 | console.log("Does this work?") # both should print the same output 12 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/js-import/js-import.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "js-import-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py"), 9 | (name = "child", esModule = "export const value = 'Child module loaded successfully';"), 10 | ], 11 | compatibilityDate = "2025-02-01", 12 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 13 | bindings = [ 14 | (name = "TEST_VALUE", text = "TEST_STRING"), 15 | ], 16 | ) 17 | ), 18 | ], 19 | ); 20 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/jspi/jspi.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "jspi", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py") 9 | ], 10 | compatibilityDate = "2024-01-15", 11 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/jspi/worker.py: -------------------------------------------------------------------------------- 1 | from asyncio import sleep 2 | 3 | from pyodide import __version__ 4 | 5 | 6 | def jspi_sleep(): 7 | if __version__ == "0.26.0a2": 8 | print("JSPI not supported on 0.26.0a2, skipping") 9 | return 10 | 11 | from pyodide.ffi import run_sync 12 | 13 | run_sync(sleep(0.1)) 14 | print("Okay") 15 | 16 | 17 | print("Testing JSPI at top level...") 18 | jspi_sleep() 19 | 20 | 21 | def test(): 22 | print("Testing JSPI in handler...") 23 | jspi_sleep() 24 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/random/random.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "python-hello", 6 | worker = ( 7 | modules = [ 8 | (name = "worker.py", pythonModule = embed "worker.py") 9 | ], 10 | compatibilityDate = "2024-01-15", 11 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 12 | ) 13 | ), 14 | ], 15 | ); 16 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/sdk/proxy.js: -------------------------------------------------------------------------------- 1 | export default { 2 | async fetch(req, env) { 3 | const url = new URL(req.url); 4 | if ( 5 | url.hostname == 'python-packages.edgeworker.net' || 6 | url.hostname == 'pyodide-packages.runtime-playground.workers.dev' 7 | ) { 8 | return env.INTERNET.fetch(req); 9 | } else if (url.hostname == 'example.com') { 10 | return env.PYTHON.fetch(req); 11 | } 12 | 13 | throw new Error('Invalid url in proxy.js: ' + url); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/seek-metadatafs/a.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pathlib import Path 3 | 4 | 5 | def test(): 6 | fh = Path(__file__).open() 7 | print(fh.fileno()) 8 | print(f"This file is {os.lseek(fh.fileno(), 0, os.SEEK_END)} characters long") 9 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/seek-metadatafs/seek-metadatafs.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "main", 6 | worker = ( 7 | modules = [ 8 | (name = "a.py", pythonModule = embed "./a.py"), 9 | ], 10 | compatibilityDate = "2023-12-18", 11 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 12 | ) 13 | ), 14 | ], 15 | ); 16 | 17 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/subdirectory/a.py: -------------------------------------------------------------------------------- 1 | from js import Response 2 | from subdir.a import x 3 | 4 | 5 | def on_fetch(request): 6 | return Response.new("hello world") 7 | 8 | 9 | def test(): 10 | print("Hi there, this is a test", x) 11 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/subdirectory/subdir/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudflare/workerd/a354d2e105621c5f87bd3a6e76a8e0fdcd4232e9/src/workerd/server/tests/python/subdirectory/subdir/__init__.py -------------------------------------------------------------------------------- /src/workerd/server/tests/python/subdirectory/subdir/a.py: -------------------------------------------------------------------------------- 1 | x = 7 2 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/subdirectory/subdirectory.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "main", 6 | worker = ( 7 | modules = [ 8 | (name = "a.py", pythonModule = embed "./a.py"), 9 | (name = "subdir/__init__.py", pythonModule = embed "./subdir/__init__.py"), 10 | (name = "subdir/a.py", pythonModule = embed "./subdir/a.py"), 11 | ], 12 | compatibilityDate = "2023-12-18", 13 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 14 | ) 15 | ), 16 | ], 17 | ); 18 | 19 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/undefined-handler/main.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/undefined-handler/server.mjs: -------------------------------------------------------------------------------- 1 | import { rejects } from 'node:assert'; 2 | 3 | export default { 4 | async test(ctrl, env) { 5 | await rejects(env.pythonWorker.fetch(new Request('http://example.com')), { 6 | name: 'Error', 7 | message: 8 | 'Python entrypoint "undefined_handler.py" does not export a handler named "on_fetch"', 9 | }); 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/undefined-handler/undefined_handler.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/vendor_dir/vendor/a.py: -------------------------------------------------------------------------------- 1 | A = 77 2 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/vendor_dir/worker.py: -------------------------------------------------------------------------------- 1 | from a import A 2 | 3 | 4 | def test(): 5 | assert A == 77 6 | -------------------------------------------------------------------------------- /src/workerd/server/tests/python/worker-entrypoint/worker-entrypoint.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const config :Workerd.Config = ( 4 | services = [ 5 | (name = "main", worker = .mainWorker), 6 | (name = "TEST_TMPDIR", disk = (writable = true)), 7 | ], 8 | ); 9 | 10 | const mainWorker :Workerd.Worker = ( 11 | compatibilityDate = "2025-03-04", 12 | 13 | compatibilityFlags = [%PYTHON_FEATURE_FLAGS], 14 | 15 | modules = [ 16 | (name = "worker.py", pythonModule = embed "worker.py"), 17 | ], 18 | 19 | bindings = [ 20 | (name = "entrypoint", service = (name = "main", entrypoint = "WorkerEntrypointExample")), 21 | ], 22 | ); 23 | -------------------------------------------------------------------------------- /src/workerd/server/tests/unsafe-eval/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | 3 | wd_test( 4 | src = "unsafe-eval-test.wd-test", 5 | data = glob([ 6 | "*.js", 7 | "*.capnp", 8 | ]), 9 | ) 10 | -------------------------------------------------------------------------------- /src/workerd/server/tests/unsafe-eval/extension.capnp: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const extension :Workerd.Extension = ( 4 | modules = [ 5 | ( name = "test:module", esModule = embed "module.js" ), 6 | ] 7 | ); 8 | -------------------------------------------------------------------------------- /src/workerd/server/tests/unsafe-eval/module.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import { default as UnsafeEval } from 'internal:unsafe-eval'; 6 | 7 | export function doEval() { 8 | return UnsafeEval.eval('1 + 1'); 9 | } 10 | -------------------------------------------------------------------------------- /src/workerd/server/tests/unsafe-eval/unsafe-eval-test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | import * as assert from 'node:assert'; 6 | import { doEval } from 'test:module'; 7 | 8 | export const test_can_use_eval_via_proxy = { 9 | async test() { 10 | assert.equal(doEval(), 2); 11 | }, 12 | }; 13 | 14 | // internal modules can't be imported 15 | export const test_cannot_import_unsafe_eval = { 16 | async test() { 17 | await assert.rejects(import('internal:unsafe-eval')); 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /src/workerd/server/tests/unsafe-eval/unsafe-eval-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | using TestExtension = import "extension.capnp"; 3 | 4 | const unitTests :Workerd.Config = ( 5 | services = [ 6 | ( name = "unsafe-eval-test", 7 | worker = ( 8 | modules = [ 9 | (name = "worker", esModule = embed "unsafe-eval-test.js") 10 | ], 11 | compatibilityDate = "2023-01-15", 12 | compatibilityFlags = ["nodejs_compat"], 13 | ) 14 | ), 15 | ], 16 | extensions = [ TestExtension.extension ], 17 | ); 18 | -------------------------------------------------------------------------------- /src/workerd/server/tests/unsafe-module/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//:build/wd_test.bzl", "wd_test") 2 | 3 | wd_test( 4 | src = "unsafe-module-test.wd-test", 5 | args = ["--experimental"], 6 | data = glob(["*.js"]), 7 | ) 8 | -------------------------------------------------------------------------------- /src/workerd/server/tests/weakref/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@aspect_rules_js//js:defs.bzl", "js_test") 2 | 3 | js_test( 4 | name = "js-weak-ref-test", 5 | data = [ 6 | ":config.capnp", 7 | ":index.mjs", 8 | "//src/workerd/server:workerd", 9 | "//src/workerd/server/tests:server-harness_js_lib", 10 | ], 11 | entry_point = "test.mjs", 12 | env = { 13 | "WORKERD_BINARY": "$(rootpath //src/workerd/server:workerd)", 14 | "WORKERD_CONFIG": "$(rootpath :config.capnp)", 15 | }, 16 | flaky = True, 17 | tags = ["js-test"], 18 | ) 19 | -------------------------------------------------------------------------------- /src/workerd/server/tests/weakref/config.capnp: -------------------------------------------------------------------------------- 1 | # config.capnp 2 | using Workerd = import "/workerd/workerd.capnp"; 3 | 4 | const config :Workerd.Config = ( 5 | v8Flags = [ "--expose-gc" ], 6 | services = [ 7 | ( name = "main", worker = .worker ), 8 | ], 9 | sockets = [ 10 | ( name = "http", address = "*:0", http = (), service = "main" ), 11 | ] 12 | ); 13 | 14 | const worker :Workerd.Worker = ( 15 | modules = [ 16 | ( name = "./index.mjs", esModule = embed "index.mjs" ) 17 | ], 18 | compatibilityDate = "2024-01-01", 19 | compatibilityFlags = ["enable_weak_ref"], 20 | ); 21 | 22 | -------------------------------------------------------------------------------- /src/workerd/server/v8-platform-impl.c++: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #include "v8-platform-impl.h" 6 | 7 | #include 8 | 9 | namespace workerd::server { 10 | 11 | double WorkerdPlatform::CurrentClockTimeMillis() noexcept { 12 | return (kj::systemPreciseCalendarClock().now() - kj::UNIX_EPOCH) / kj::MILLISECONDS; 13 | } 14 | 15 | } // namespace workerd::server 16 | -------------------------------------------------------------------------------- /src/workerd/server/workerd-meta.capnp: -------------------------------------------------------------------------------- 1 | @0xfec9bacd5b113388; 2 | # We embed the original text of the config schema so that it doesn't have to be accessible on the 3 | # filesystem when parsing a workerd config file. 4 | 5 | $import "/capnp/c++.capnp".namespace("workerd::server"); 6 | 7 | const cppCapnpSchema :Text = embed "/capnp/c++.capnp"; 8 | const workerdCapnpSchema :Text = embed "workerd.capnp"; 9 | -------------------------------------------------------------------------------- /src/workerd/tests/performance-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "performance-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "performance-test.js") 9 | ], 10 | compatibilityDate = "2023-01-15", 11 | ) 12 | ), 13 | ], 14 | ); 15 | -------------------------------------------------------------------------------- /src/workerd/tests/unknown-import-assertions-test.js: -------------------------------------------------------------------------------- 1 | import { rejects } from 'node:assert'; 2 | 3 | export const test = { 4 | async test() { 5 | await rejects(import('worker', { with: { a: 'b' } }), { 6 | message: /Unrecognized import attributes/, 7 | }); 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /src/workerd/tests/unknown-import-assertions-test.wd-test: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const unitTests :Workerd.Config = ( 4 | services = [ 5 | ( name = "unknown-import-assertions-test", 6 | worker = ( 7 | modules = [ 8 | (name = "worker", esModule = embed "unknown-import-assertions-test.js") 9 | ], 10 | compatibilityDate = "2025-05-01", 11 | compatibilityFlags = [ 12 | "nodejs_compat", 13 | "throw_on_unrecognized_import_assertion", 14 | ] 15 | ) 16 | ), 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /src/workerd/util/exception.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace workerd { 10 | 11 | // If an exception is thrown for exceeding memory limits, it will contain this detail. 12 | constexpr kj::Exception::DetailTypeId MEMORY_LIMIT_DETAIL_ID = 0xbaf76dd7ce5bd8cfull; 13 | 14 | } // namespace workerd 15 | -------------------------------------------------------------------------------- /src/workerd/util/use-perfetto-categories.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // This header is to be imported by any translation unit (c++ file) that 6 | // is instrumenting with perfetto traces (e.g. TRACE_EVENT). Header files 7 | // that include instrumentation but are imported by embedders should instead 8 | // use PERFETTO_USE_CATEGORY_FROM_NAMESPACE_SCOPED within function or block 9 | // scopes that are to be instrumented. 10 | 11 | #if defined(WORKERD_USE_PERFETTO) 12 | PERFETTO_USE_CATEGORIES_FROM_NAMESPACE(workerd::traces); 13 | #endif 14 | -------------------------------------------------------------------------------- /src/workerd/util/websocket-error-handler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace workerd { 7 | class JsgifyWebSocketErrors final: public kj::WebSocketErrorHandler { 8 | public: 9 | // Does what kj::WebSocketErrorHandler does, but formatted as a JSG exception. 10 | kj::Exception handleWebSocketProtocolError(kj::WebSocket::ProtocolError protocolError) override; 11 | }; 12 | 13 | } // namespace workerd 14 | -------------------------------------------------------------------------------- /src/wpt/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { baseConfig } from '../../tools/base.eslint.config.mjs'; 2 | 3 | export default [ 4 | ...baseConfig(), 5 | { 6 | files: ['src/wpt/**/*-test.ts'], 7 | rules: { 8 | 'sort-keys': 'error', 9 | }, 10 | }, 11 | ]; 12 | -------------------------------------------------------------------------------- /tools/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@aspect_rules_js//js:defs.bzl", "js_library") 2 | 3 | js_library( 4 | name = "base-eslint", 5 | srcs = ["base.eslint.config.mjs"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//:node_modules/@eslint/js", 9 | "//:node_modules/@types/node", 10 | "//:node_modules/typescript-eslint", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /tools/cross/format.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "directory": "src/workerd", 4 | "globs": ["*.c++", "*.h"], 5 | "formatter": "clang-format" 6 | }, 7 | { 8 | "directory": "src", 9 | "globs": ["*.js", "*.ts", "*.cjs", "*.ejs", "*.mjs"], 10 | "formatter": "prettier" 11 | }, 12 | { 13 | "directory": "src", 14 | "globs": ["*.json"], 15 | "formatter": "prettier" 16 | }, 17 | { 18 | "directory": ".", 19 | "globs": ["*.py"], 20 | "formatter": "ruff" 21 | }, 22 | { 23 | "directory": ".", 24 | "globs": ["*.bzl", "WORKSPACE", "BUILD", "BUILD.*"], 25 | "formatter": "buildifier" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /tools/unix/find-python3.sh: -------------------------------------------------------------------------------- 1 | 2 | get_python3() { 3 | # Search for python3 4 | python=$(which python3 2>/dev/null) 5 | 6 | # If not found, search for python 7 | if [ -z "$python" ]; then 8 | python=$(which python 2>/dev/null) 9 | if [ -n "$python" ]; then 10 | local python_version=$($python -V 2>&1 | head -n 1 | cut -d ' ' -f 2- | cut -d '.' -f1) 11 | if [ "$python_version" != "3" ]; then 12 | unset python 13 | fi 14 | fi 15 | fi 16 | 17 | if [ -z "$python" ]; then 18 | return 19 | fi 20 | echo "$python" 21 | } 22 | -------------------------------------------------------------------------------- /tools/unix/upload-python-bundle.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) 4 | 5 | gh workflow run 105611493 \ 6 | --field pyodide=$1 \ 7 | --field pyodideRevision=$2 \ 8 | --field backport=$3 \ 9 | -r $BRANCH_NAME 10 | -------------------------------------------------------------------------------- /tools/windows/bazel-env.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo.* Environment configured for workerd builds with bazel 3 | echo. 4 | 5 | rem Set environment variables for bazel to use when invoked from 6 | rem the command-line. 7 | set "BAZEL_LLVM=C:\Program Files\LLVM" 8 | set BAZEL_SH=C:\msys64\usr\bin\bash.exe 9 | set "BAZEL_VC=C:\Program Files\Microsoft Visual Studio\2022\Community\VC" 10 | set BAZEL_WINSDK_FULL_VERSION=10.0.22000.0 11 | -------------------------------------------------------------------------------- /tools/windows/workspace-status.cmd: -------------------------------------------------------------------------------- 1 | @setlocal enabledelayedexpansion 2 | @echo off 3 | 4 | @rem find git.exe 5 | for /F "tokens=* USEBACKQ" %%F in (`where git.exe`) do ( 6 | set "GIT=%%F" 7 | break 8 | ) 9 | 10 | @rem Git's bash is located at %GITINSTALLDIR%\bin\bash.exe 11 | @rem Git's git.exe is typically located at %GITINSTALLDIR%\cmd\git.exe or 12 | @rem %GITINSTALLDIR%\mingw64\bin\git.exe. 13 | set "_GITEXEDIR=%GIT:\cmd\git.exe=%" 14 | set "GITEXEDIR=%_GITEXEDIR:\mingw64\bin\git.exe=%" 15 | set "BASH=%GITEXEDIR%\bin\bash.exe" 16 | 17 | @rem Change to the directory of this script (tools/windows) to 18 | @rem run bash script in (tools/unix). 19 | cd "%~dp0" 20 | "%BASH%" -c ../unix/workspace-status.sh 21 | -------------------------------------------------------------------------------- /types/defines/disposable.d.ts: -------------------------------------------------------------------------------- 1 | // `Disposable` was added to TypeScript's standard lib types in version 5.2. 2 | // To support older TypeScript versions, define an empty `Disposable` interface. 3 | // Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2, 4 | // but this will ensure type checking on older versions still passes. 5 | // TypeScript's interface merging will ensure our empty interface is effectively 6 | // ignored when `Disposable` is included in the standard lib. 7 | interface Disposable {} 8 | -------------------------------------------------------------------------------- /types/defines/ratelimit.d.ts: -------------------------------------------------------------------------------- 1 | interface RateLimitOptions { 2 | key: string 3 | } 4 | 5 | interface RateLimitOutcome { 6 | success: boolean 7 | } 8 | 9 | interface RateLimit { 10 | /** 11 | * Rate limit a request based on the provided options. 12 | * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/ 13 | * @returns A promise that resolves with the outcome of the rate limit. 14 | */ 15 | limit(options: RateLimitOptions): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /types/defines/secrets-store.d.ts: -------------------------------------------------------------------------------- 1 | interface SecretsStoreSecret { 2 | /** 3 | * Get a secret from the Secrets Store, returning a string of the secret value 4 | * if it exists, or throws an error if it does not exist 5 | */ 6 | get(): Promise; 7 | } 8 | -------------------------------------------------------------------------------- /types/defines/sockets.d.ts: -------------------------------------------------------------------------------- 1 | declare module "cloudflare:sockets" { 2 | function _connect(address: string | SocketAddress, options?: SocketOptions): Socket; 3 | export { _connect as connect }; 4 | } 5 | -------------------------------------------------------------------------------- /types/defines/versions.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The interface for "version_metadata" binding 3 | * providing metadata about the Worker Version using this binding. 4 | */ 5 | export type WorkerVersionMetadata = { 6 | /** The ID of the Worker Version using this binding */ 7 | id: string; 8 | /** The tag of the Worker Version using this binding */ 9 | tag: string; 10 | /** The timestamp of when the Worker Version was uploaded */ 11 | timestamp: string; 12 | } 13 | -------------------------------------------------------------------------------- /types/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { baseConfig } from '../tools/base.eslint.config.mjs'; 2 | 3 | export default [ 4 | ...baseConfig(), 5 | { 6 | rules: { 7 | '@typescript-eslint/ban-ts-comment': 'off', 8 | '@typescript-eslint/no-non-null-assertion': 'off', 9 | '@typescript-eslint/no-explicit-any': 'off', 10 | '@typescript-eslint/no-empty-function': 'off', 11 | '@typescript-eslint/no-floating-promises': 'off', 12 | '@typescript-eslint/no-unused-vars': [ 13 | 'error', 14 | { argsIgnorePattern: '^_' }, 15 | ], 16 | }, 17 | }, 18 | ]; 19 | -------------------------------------------------------------------------------- /types/scripts/config.capnp: -------------------------------------------------------------------------------- 1 | using Workerd = import "/workerd/workerd.capnp"; 2 | 3 | const config :Workerd.Config = ( 4 | services = [ 5 | ( name = "main", worker = .worker ), 6 | ], 7 | sockets = [ 8 | ( name = "http", address = "127.0.0.1:0", http = (), service = "main" ), 9 | ] 10 | ); 11 | 12 | const worker :Workerd.Worker = ( 13 | compatibilityDate = "2024-01-01", 14 | compatibilityFlags = ["nodejs_compat", "rtti_api"], 15 | modules = [ 16 | ( name = "./index.mjs", esModule = embed "../dist/index.mjs" ) 17 | ], 18 | ); 19 | -------------------------------------------------------------------------------- /types/src/transforms/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022-2023 Cloudflare, Inc. 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: 3 | // https://opensource.org/licenses/Apache-2.0 4 | 5 | export * from "./ambient"; 6 | export * from "./comments"; 7 | export * from "./globals"; 8 | export * from "./import-resolve"; 9 | export * from "./importable"; 10 | export * from "./internal-namespace"; 11 | export * from "./iterators"; 12 | export * from "./overrides"; 13 | -------------------------------------------------------------------------------- /types/src/utils.ts: -------------------------------------------------------------------------------- 1 | import { existsSync } from "node:fs"; 2 | import path from "node:path"; 3 | 4 | // When building types from the upstream repo all paths need to be prepended by external/workerd/ 5 | export function getFilePath(f: string): string { 6 | if (existsSync("external/workerd")) { 7 | return path.join("external", "workerd", f); 8 | } else { 9 | return f; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /types/src/worker/raw.d.ts: -------------------------------------------------------------------------------- 1 | declare module "raw:*" { 2 | const text: string; 3 | export { text as default }; 4 | } 5 | -------------------------------------------------------------------------------- /types/src/worker/rtti.d.ts: -------------------------------------------------------------------------------- 1 | declare module "workerd:rtti" { 2 | const api: { 3 | exportExperimentalTypes(): ArrayBuffer; 4 | exportTypes(compatDate: string, compatFlags: string[]): ArrayBuffer; 5 | }; 6 | export { api as default }; 7 | } 8 | -------------------------------------------------------------------------------- /types/src/worker/virtual.d.ts: -------------------------------------------------------------------------------- 1 | declare module "virtual:comments.json" { 2 | const data: import("../transforms").CommentsData; 3 | export { data as default }; 4 | } 5 | 6 | declare module "virtual:param-names.json" { 7 | const data: import("../generator/parameter-names").ParameterNamesData; 8 | export { data as default }; 9 | } 10 | -------------------------------------------------------------------------------- /types/test/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "esnext", 5 | "moduleResolution": "bundler", 6 | "lib": ["esnext"], 7 | "strict": true, 8 | "types": ["../../../bazel-bin/types/definitions/experimental"], 9 | "noEmit": true 10 | }, 11 | "include": ["**/*.ts"] 12 | } 13 | --------------------------------------------------------------------------------