Skip to content

Commit 0b742a7

Browse files
feat: add Bun globals (#275)
* feat: add Bun globals * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent cbb7b44 commit 0b742a7

5 files changed

Lines changed: 189 additions & 49 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Rust fork of https://npmx.dev/package/globals
2424
- `es2026`
2525
- `audioworklet`
2626
- `browser`
27+
- `bun`
2728
- `node`
2829
- `shared-node-browser`
2930
- `worker`

pnpm-lock.yaml

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 175 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,138 @@ pub static GLOBALS_BROWSER: phf::Map<&'static str, bool> = ::phf::Map {
23852385
],
23862386
};
23872387

2388+
#[rustfmt::skip]
2389+
pub static GLOBALS_BUN: phf::Map<&'static str, bool> = ::phf::Map {
2390+
key: 16287231350648472473,
2391+
disps: &[
2392+
(1, 0),
2393+
(0, 0),
2394+
(0, 50),
2395+
(0, 6),
2396+
(0, 10),
2397+
(0, 39),
2398+
(0, 8),
2399+
(0, 0),
2400+
(0, 3),
2401+
(0, 64),
2402+
(0, 3),
2403+
(0, 5),
2404+
(0, 0),
2405+
(0, 12),
2406+
(0, 9),
2407+
(0, 38),
2408+
(0, 5),
2409+
(0, 4),
2410+
(0, 37),
2411+
(0, 0),
2412+
(0, 0),
2413+
(0, 50),
2414+
(0, 8),
2415+
(0, 2),
2416+
(0, 47),
2417+
(2, 44),
2418+
(0, 32),
2419+
(0, 59),
2420+
(1, 23),
2421+
(0, 32),
2422+
(0, 12),
2423+
],
2424+
entries: &[
2425+
("HTMLRewriter", false),
2426+
("FormData", false),
2427+
("WritableStreamDefaultWriter", false),
2428+
("CustomEvent", false),
2429+
("PerformanceEntry", false),
2430+
("process", false),
2431+
("File", false),
2432+
("DecompressionStream", false),
2433+
("Worker", false),
2434+
("BuildError", false),
2435+
("Buffer", false),
2436+
("MessagePort", false),
2437+
("setTimeout", false),
2438+
("removeEventListener", false),
2439+
("onerror", true),
2440+
("ReadableStreamDefaultController", false),
2441+
("clearInterval", false),
2442+
("EventTarget", false),
2443+
("AbortController", false),
2444+
("SubtleCrypto", false),
2445+
("ResolveError", false),
2446+
("Blob", false),
2447+
("TextDecoder", false),
2448+
("setInterval", false),
2449+
("BroadcastChannel", false),
2450+
("TransformStreamDefaultController", false),
2451+
("onmessage", true),
2452+
("PerformanceObserverEntryList", false),
2453+
("setImmediate", false),
2454+
("URL", false),
2455+
("Crypto", false),
2456+
("AbortSignal", false),
2457+
("navigator", false),
2458+
("ErrorEvent", false),
2459+
("DOMException", false),
2460+
("prompt", false),
2461+
("URLSearchParams", false),
2462+
("clearImmediate", false),
2463+
("ResolveMessage", false),
2464+
("Headers", false),
2465+
("PerformanceMark", false),
2466+
("clearTimeout", false),
2467+
("MessageEvent", false),
2468+
("btoa", false),
2469+
("Event", false),
2470+
("console", false),
2471+
("postMessage", false),
2472+
("Response", false),
2473+
("ReadableStream", false),
2474+
("Performance", false),
2475+
("self", false),
2476+
("ByteLengthQueuingStrategy", false),
2477+
("TransformStream", false),
2478+
("reportError", false),
2479+
("WritableStreamDefaultController", false),
2480+
("URLPattern", false),
2481+
("CryptoKey", false),
2482+
("WebSocket", false),
2483+
("ReadableByteStreamController", false),
2484+
("structuredClone", false),
2485+
("Loader", false),
2486+
("TextEncoder", false),
2487+
("confirm", false),
2488+
("global", false),
2489+
("ShadowRealm", false),
2490+
("atob", false),
2491+
("CountQueuingStrategy", false),
2492+
("addEventListener", false),
2493+
("WebAssembly", false),
2494+
("PerformanceServerTiming", false),
2495+
("queueMicrotask", false),
2496+
("MessageChannel", false),
2497+
("CloseEvent", false),
2498+
("ReadableStreamBYOBRequest", false),
2499+
("WritableStream", false),
2500+
("fetch", false),
2501+
("BuildMessage", false),
2502+
("ReadableStreamBYOBReader", false),
2503+
("PerformanceResourceTiming", false),
2504+
("CompressionStream", false),
2505+
("Request", false),
2506+
("PerformanceMeasure", false),
2507+
("Bun", false),
2508+
("performance", false),
2509+
("PerformanceObserver", false),
2510+
("alert", false),
2511+
("TextDecoderStream", false),
2512+
("ReadableStreamDefaultReader", false),
2513+
("dispatchEvent", false),
2514+
("TextEncoderStream", false),
2515+
("crypto", false),
2516+
("PerformanceTiming", false),
2517+
],
2518+
};
2519+
23882520
#[rustfmt::skip]
23892521
pub static GLOBALS_NODE: phf::Map<&'static str, bool> = ::phf::Map {
23902522
key: 16287231350648472473,
@@ -4220,65 +4352,66 @@ pub static GLOBALS_VUE: phf::Map<&'static str, bool> = ::phf::Map {
42204352
pub static GLOBALS: Globals = Globals(::phf::Map {
42214353
key: 16287231350648472473,
42224354
disps: &[
4223-
(1, 0),
4224-
(0, 9),
4355+
(0, 7),
4356+
(0, 26),
42254357
(0, 0),
4226-
(0, 2),
4358+
(0, 12),
42274359
(0, 0),
4228-
(0, 31),
4229-
(0, 21),
4230-
(1, 0),
4360+
(0, 5),
42314361
(0, 0),
4362+
(0, 5),
4363+
(0, 0),
4364+
(0, 13),
4365+
(1, 4),
4366+
(2, 17),
4367+
(1, 12),
42324368
(0, 32),
4233-
(0, 21),
42344369
(1, 0),
4235-
(4, 1),
4236-
(0, 30),
4237-
(0, 0),
42384370
],
42394371
entries: &[
4240-
("es2024", &GLOBALS_ES2024),
4241-
("es2017", &GLOBALS_ES2017),
4242-
("meteor", &GLOBALS_METEOR),
4243-
("es2022", &GLOBALS_ES2022),
4244-
("es2018", &GLOBALS_ES2018),
4245-
("qunit", &GLOBALS_QUNIT),
4246-
("mocha", &GLOBALS_MOCHA),
4372+
("es2019", &GLOBALS_ES2019),
4373+
("nashorn", &GLOBALS_NASHORN),
4374+
("atomtest", &GLOBALS_ATOMTEST),
4375+
("mongo", &GLOBALS_MONGO),
4376+
("vue", &GLOBALS_VUE),
42474377
("shelljs", &GLOBALS_SHELLJS),
4248-
("jasmine", &GLOBALS_JASMINE),
4249-
("es6", &GLOBALS_ES6),
4250-
("jquery", &GLOBALS_JQUERY),
4378+
("astro", &GLOBALS_ASTRO),
42514379
("jest", &GLOBALS_JEST),
4252-
("worker", &GLOBALS_WORKER),
4253-
("browser", &GLOBALS_BROWSER),
4254-
("es2026", &GLOBALS_ES2026),
4255-
("node", &GLOBALS_NODE),
4256-
("atomtest", &GLOBALS_ATOMTEST),
42574380
("phantomjs", &GLOBALS_PHANTOMJS),
4258-
("es2019", &GLOBALS_ES2019),
4259-
("webextensions", &GLOBALS_WEBEXTENSIONS),
4260-
("prototypejs", &GLOBALS_PROTOTYPEJS),
4261-
("mongo", &GLOBALS_MONGO),
4381+
("serviceworker", &GLOBALS_SERVICEWORKER),
4382+
("svelte", &GLOBALS_SVELTE),
4383+
("es2017", &GLOBALS_ES2017),
4384+
("node", &GLOBALS_NODE),
4385+
("meteor", &GLOBALS_METEOR),
42624386
("shared-node-browser", &GLOBALS_SHARED_NODE_BROWSER),
4263-
("vue", &GLOBALS_VUE),
4264-
("es2023", &GLOBALS_ES2023),
42654387
("greasemonkey", &GLOBALS_GREASEMONKEY),
4266-
("svelte", &GLOBALS_SVELTE),
4267-
("audioworklet", &GLOBALS_AUDIOWORKLET),
4268-
("astro", &GLOBALS_ASTRO),
42694388
("es2015", &GLOBALS_ES2015),
4389+
("mocha", &GLOBALS_MOCHA),
4390+
("es6", &GLOBALS_ES6),
4391+
("es2020", &GLOBALS_ES2020),
4392+
("applescript", &GLOBALS_APPLESCRIPT),
4393+
("bun", &GLOBALS_BUN),
4394+
("worker", &GLOBALS_WORKER),
4395+
("es2022", &GLOBALS_ES2022),
42704396
("es2025", &GLOBALS_ES2025),
4271-
("es2021", &GLOBALS_ES2021),
4272-
("commonjs", &GLOBALS_COMMONJS),
4397+
("prototypejs", &GLOBALS_PROTOTYPEJS),
4398+
("es2024", &GLOBALS_ES2024),
42734399
("amd", &GLOBALS_AMD),
4274-
("es2020", &GLOBALS_ES2020),
4275-
("nashorn", &GLOBALS_NASHORN),
4276-
("protractor", &GLOBALS_PROTRACTOR),
4277-
("serviceworker", &GLOBALS_SERVICEWORKER),
4400+
("commonjs", &GLOBALS_COMMONJS),
4401+
("es2018", &GLOBALS_ES2018),
4402+
("qunit", &GLOBALS_QUNIT),
4403+
("audioworklet", &GLOBALS_AUDIOWORKLET),
4404+
("es2023", &GLOBALS_ES2023),
4405+
("webextensions", &GLOBALS_WEBEXTENSIONS),
42784406
("builtin", &GLOBALS_BUILTIN),
4279-
("vitest", &GLOBALS_VITEST),
4280-
("applescript", &GLOBALS_APPLESCRIPT),
42814407
("embertest", &GLOBALS_EMBERTEST),
4408+
("es2021", &GLOBALS_ES2021),
4409+
("browser", &GLOBALS_BROWSER),
4410+
("protractor", &GLOBALS_PROTRACTOR),
42824411
("es2016", &GLOBALS_ES2016),
4412+
("es2026", &GLOBALS_ES2026),
4413+
("vitest", &GLOBALS_VITEST),
4414+
("jasmine", &GLOBALS_JASMINE),
4415+
("jquery", &GLOBALS_JQUERY),
42834416
],
42844417
});

tests/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use javascript_globals::{GLOBALS, GLOBALS_BUILTIN};
1+
use javascript_globals::{GLOBALS, GLOBALS_BUILTIN, GLOBALS_BUN};
22

33
#[test]
44
fn test() {
@@ -9,3 +9,9 @@ fn test() {
99
fn test_individual_static() {
1010
assert!(!GLOBALS_BUILTIN["Date"]);
1111
}
12+
13+
#[test]
14+
fn test_bun_environment() {
15+
assert!(!GLOBALS["bun"]["Bun"]);
16+
assert!(!GLOBALS_BUN["Bun"]);
17+
}

xtask/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ fn main() {
145145
// Platforms
146146
("audioworklet", &globals["audioWorklet"]),
147147
("browser", &globals["browser"]),
148+
("bun", &globals["bunBuiltin"]),
148149
("node", &globals["node"]),
149150
("shared-node-browser", &globals["shared-node-browser"]),
150151
("worker", &globals["worker"]),

0 commit comments

Comments
 (0)