diff options
author | Julien Cayzac <jcayzac@users.noreply.github.com> | 2023-12-08 22:24:49 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 14:24:49 +0100 |
commit | ca64771257d23ceee97e882965269702c359f6aa (patch) | |
tree | 7b348cdba31e60f7988c032672530a21fdeb2a56 /runtime/js/90_deno_ns.js | |
parent | e15c735edee6a6faf17f618b245908f635a3d9a7 (diff) |
fix(unstable): Honor granular unstable flags in js runtime (#21466)
This fixes #21434 for `BroadcastChannel` and `WebSocketStream`.
`--unstable` still enable both, but granular unstable flags now also
work:
* `--unstable-net` now enables `WebSocketStream`.
* `--unstable-broadcast-channel` now enables `BroadcastChannel`.
* Additionally, there are now tests for all granular unstable flags.
Since `unsafe-proto` already had tests, so I didn't add any for this
one.
It also introduces a map to keep track of granular unstable ids without
having to sync multiple places.
Diffstat (limited to 'runtime/js/90_deno_ns.js')
-rw-r--r-- | runtime/js/90_deno_ns.js | 119 |
1 files changed, 62 insertions, 57 deletions
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 834e5d1a3..83c4a4d03 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -155,64 +155,69 @@ const denoNs = { }; // NOTE(bartlomieju): keep IDs in sync with `cli/main.rs` -const denoNsUnstableById = { - // BroadcastChannel is always available? - // 1: {}, - - 2: { - cron: cron.cron, - }, - - // FFI - 3: { - dlopen: ffi.dlopen, - UnsafeCallback: ffi.UnsafeCallback, - UnsafePointer: ffi.UnsafePointer, - UnsafePointerView: ffi.UnsafePointerView, - UnsafeFnPointer: ffi.UnsafeFnPointer, - }, - - // FS - 4: { - flock: fs.flock, - flockSync: fs.flockSync, - funlock: fs.funlock, - funlockSync: fs.funlockSync, - umask: fs.umask, - }, - - // HTTP - 5: { - HttpClient: httpClient.HttpClient, - createHttpClient: httpClient.createHttpClient, - // TODO(bartlomieju): why is it needed? - http, - upgradeHttp: http.upgradeHttp, - }, - - // KV - 6: { - openKv: kv.openKv, - AtomicOperation: kv.AtomicOperation, - Kv: kv.Kv, - KvU64: kv.KvU64, - KvListIterator: kv.KvListIterator, - }, - - // net - 7: { - listenDatagram: net.createListenDatagram( - ops.op_net_listen_udp, - ops.op_net_listen_unixpacket, - ), - }, - // Unsafe proto - // 8: {}, - - // Worker options - // 9: {} +const unstableIds = { + broadcastChannel: 1, + cron: 2, + ffi: 3, + fs: 4, + http: 5, + kv: 6, + net: 7, + unsafeProto: 8, + workerOptions: 9, }; +const denoNsUnstableById = {}; + +// denoNsUnstableById[unstableIds.broadcastChannel] = {} + +denoNsUnstableById[unstableIds.cron] = { + cron: cron.cron, +}; + +denoNsUnstableById[unstableIds.ffi] = { + dlopen: ffi.dlopen, + UnsafeCallback: ffi.UnsafeCallback, + UnsafePointer: ffi.UnsafePointer, + UnsafePointerView: ffi.UnsafePointerView, + UnsafeFnPointer: ffi.UnsafeFnPointer, +}; + +denoNsUnstableById[unstableIds.fs] = { + flock: fs.flock, + flockSync: fs.flockSync, + funlock: fs.funlock, + funlockSync: fs.funlockSync, + umask: fs.umask, +}; + +denoNsUnstableById[unstableIds.http] = { + HttpClient: httpClient.HttpClient, + createHttpClient: httpClient.createHttpClient, + // TODO(bartlomieju): why is it needed? + http, + upgradeHttp: http.upgradeHttp, +}; + +denoNsUnstableById[unstableIds.kv] = { + openKv: kv.openKv, + AtomicOperation: kv.AtomicOperation, + Kv: kv.Kv, + KvU64: kv.KvU64, + KvListIterator: kv.KvListIterator, +}; + +denoNsUnstableById[unstableIds.net] = { + listenDatagram: net.createListenDatagram( + ops.op_net_listen_udp, + ops.op_net_listen_unixpacket, + ), +}; + +// denoNsUnstableById[unstableIds.unsafeProto] = {} + +// denoNsUnstableById[unstableIds.workerOptions] = {} + // when editing this list, also update unstableDenoProps in cli/tsc/99_main_compiler.js const denoNsUnstable = { listenDatagram: net.createListenDatagram( @@ -242,4 +247,4 @@ const denoNsUnstable = { cron: cron.cron, }; -export { denoNs, denoNsUnstable, denoNsUnstableById }; +export { denoNs, denoNsUnstable, denoNsUnstableById, unstableIds }; |