diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-28 14:44:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 14:44:22 +0200 |
commit | e5b2815b3943cd39038bba00da462082c6988e6e (patch) | |
tree | 54953513a9c2947dcb2611f079512d07a0f5a0c9 /ext/node/polyfills | |
parent | 10012c2fe312a4f7ddc5217adaa6718c91bfb819 (diff) |
Reland "refactor: remove Deno[Deno.internal].nodeUnstable namespace" (#18475)
This reverts commit 357bcfcf79fee92195e37bb3f05e247908f207c5.
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r-- | ext/node/polyfills/http.ts | 10 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/udp_wrap.ts | 11 | ||||
-rw-r--r-- | ext/node/polyfills/os.ts | 8 |
3 files changed, 14 insertions, 15 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 87b19972f..b99e7afab 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1,5 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +const core = globalThis.Deno.core; +const ops = core.ops; import { TextEncoder } from "ext:deno_web/08_text_encoding.js"; import { type Deferred, deferred } from "ext:deno_node/_util/async.ts"; import { _normalizeArgs, ListenOptions, Socket } from "ext:deno_node/net.ts"; @@ -17,6 +19,7 @@ import { Agent } from "ext:deno_node/_http_agent.mjs"; import { chunkExpression as RE_TE_CHUNKED } from "ext:deno_node/_http_common.ts"; import { urlToHttpOptions } from "ext:deno_node/internal/url.ts"; import { constants, TCP } from "ext:deno_node/internal_binding/tcp_wrap.ts"; +import * as flash from "ext:deno_flash/01_http.js"; enum STATUS_CODES { /** RFC 7231, 6.2.1 */ @@ -188,11 +191,8 @@ const METHODS = [ type Chunk = string | Buffer | Uint8Array; -// @ts-ignore Deno[Deno.internal] is used on purpose here -const DenoServe = Deno[Deno.internal]?.nodeUnstable?.serve || Deno.serve; -// @ts-ignore Deno[Deno.internal] is used on purpose here -const DenoUpgradeHttpRaw = Deno[Deno.internal]?.nodeUnstable?.upgradeHttpRaw || - Deno.upgradeHttpRaw; +const DenoServe = flash.createServe(ops.op_node_unstable_flash_serve); +const DenoUpgradeHttpRaw = flash.upgradeHttpRaw; const ENCODER = new TextEncoder(); diff --git a/ext/node/polyfills/internal_binding/udp_wrap.ts b/ext/node/polyfills/internal_binding/udp_wrap.ts index b36334a54..2b25ccb42 100644 --- a/ext/node/polyfills/internal_binding/udp_wrap.ts +++ b/ext/node/polyfills/internal_binding/udp_wrap.ts @@ -20,6 +20,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +const core = globalThis.Deno.core; +const ops = core.ops; import { AsyncWrap, providerType, @@ -32,12 +34,13 @@ import { notImplemented } from "ext:deno_node/_utils.ts"; import { Buffer } from "ext:deno_node/buffer.ts"; import type { ErrnoException } from "ext:deno_node/internal/errors.ts"; import { isIP } from "ext:deno_node/internal/net.ts"; - +import * as net from "ext:deno_net/01_net.js"; import { isLinux, isWindows } from "ext:deno_node/_util/os.ts"; -// @ts-ignore Deno[Deno.internal] is used on purpose here -const DenoListenDatagram = Deno[Deno.internal]?.nodeUnstable?.listenDatagram || - Deno.listenDatagram; +const DenoListenDatagram = net.createListenDatagram( + ops.op_node_unstable_net_listen_udp, + ops.op_node_unstable_net_listen_unixpacket, +); type MessageType = string | Uint8Array | Buffer | DataView; diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts index 69ca19bc5..19e8fd155 100644 --- a/ext/node/polyfills/os.ts +++ b/ext/node/polyfills/os.ts @@ -25,15 +25,11 @@ import { validateIntegerRange } from "ext:deno_node/_utils.ts"; import process from "ext:deno_node/process.ts"; import { isWindows, osType } from "ext:deno_node/_util/os.ts"; import { os } from "ext:deno_node/internal_binding/constants.ts"; - +import { osUptime } from "ext:runtime/30_os.js"; export const constants = os; const SEE_GITHUB_ISSUE = "See https://github.com/denoland/deno_std/issues/1436"; -// @ts-ignore Deno[Deno.internal] is used on purpose here -const DenoOsUptime = Deno[Deno.internal]?.nodeUnstable?.osUptime || - Deno.osUptime; - interface CPUTimes { /** The number of milliseconds the CPU has spent in user mode */ user: number; @@ -310,7 +306,7 @@ export function type(): string { /** Returns the Operating System uptime in number of seconds. */ export function uptime(): number { - return DenoOsUptime(); + return osUptime(); } /** Not yet implemented */ |