diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dacd87..6ef4d90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - uses: denoland/setup-deno@v1 with: - deno-version: 1.40.2 + deno-version: 1.43.3 - run: deno lint if: matrix.os == 'ubuntu-latest' - run: deno fmt --check diff --git a/package-lock.json b/package-lock.json index 62023ef..c78cddf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -100,18 +100,18 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", - "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/@types/which": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.2.tgz", - "integrity": "sha512-UqCG7NjNyume6e+BHcFkOQOS8of/E18V2z/jTRkiD98YiiryYOFBVvPxqA/8PQCwkn7icKqz/hFflMIRN2HGhQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.3.tgz", + "integrity": "sha512-2C1+XoY0huExTbs8MQv1DuS5FS86+SEjdM9F/+GS61gg5Hqbtj8ZiDSx8MfWcyei907fIPbfPGCOrNUTnVHY1g==", "dev": true }, "node_modules/acorn": { @@ -171,9 +171,9 @@ "dev": true }, "node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", @@ -214,9 +214,9 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -266,8 +266,8 @@ "version": "0.1.0", "license": "MIT", "devDependencies": { - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } }, "packages/shim-crypto": { @@ -275,8 +275,8 @@ "version": "0.3.1", "license": "MIT", "devDependencies": { - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } }, "packages/shim-deno": { @@ -288,10 +288,10 @@ "which": "^4.0.0" }, "devDependencies": { - "@types/node": "^20.9.0", - "@types/which": "^3.0.2", - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "@types/node": "^20.12.12", + "@types/which": "^3.0.3", + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } }, "packages/shim-deno-test": { @@ -299,7 +299,7 @@ "version": "0.5.0", "license": "MIT", "devDependencies": { - "typescript": "^5.2.2" + "typescript": "^5.4.5" } }, "packages/shim-prompts": { @@ -307,8 +307,8 @@ "version": "0.1.1", "license": "MIT", "devDependencies": { - "@types/node": "^20.9.0", - "typescript": "^5.2.2" + "@types/node": "^20.12.12", + "typescript": "^5.4.5" } }, "packages/shim-timers": { @@ -316,8 +316,8 @@ "version": "0.1.0", "license": "MIT", "devDependencies": { - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } } }, @@ -334,46 +334,46 @@ "@deno/sham-weakref": { "version": "file:packages/sham-weakref", "requires": { - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } }, "@deno/shim-crypto": { "version": "file:packages/shim-crypto", "requires": { - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } }, "@deno/shim-deno": { "version": "file:packages/shim-deno", "requires": { "@deno/shim-deno-test": "^0.5.0", - "@types/node": "^20.9.0", - "@types/which": "^3.0.2", - "ts-node": "^10.9.1", - "typescript": "^5.2.2", + "@types/node": "^20.12.12", + "@types/which": "^3.0.3", + "ts-node": "^10.9.2", + "typescript": "^5.4.5", "which": "^4.0.0" } }, "@deno/shim-deno-test": { "version": "file:packages/shim-deno-test", "requires": { - "typescript": "^5.2.2" + "typescript": "^5.4.5" } }, "@deno/shim-prompts": { "version": "file:packages/shim-prompts", "requires": { - "@types/node": "^20.9.0", - "typescript": "^5.2.2" + "@types/node": "^20.12.12", + "typescript": "^5.4.5" } }, "@deno/shim-timers": { "version": "file:packages/shim-timers", "requires": { - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } }, "@jridgewell/resolve-uri": { @@ -423,18 +423,18 @@ "dev": true }, "@types/node": { - "version": "20.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", - "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", "dev": true, "requires": { "undici-types": "~5.26.4" } }, "@types/which": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.2.tgz", - "integrity": "sha512-UqCG7NjNyume6e+BHcFkOQOS8of/E18V2z/jTRkiD98YiiryYOFBVvPxqA/8PQCwkn7icKqz/hFflMIRN2HGhQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.3.tgz", + "integrity": "sha512-2C1+XoY0huExTbs8MQv1DuS5FS86+SEjdM9F/+GS61gg5Hqbtj8ZiDSx8MfWcyei907fIPbfPGCOrNUTnVHY1g==", "dev": true }, "acorn": { @@ -479,9 +479,9 @@ "dev": true }, "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "requires": { "@cspotcode/source-map-support": "^0.8.0", @@ -500,9 +500,9 @@ } }, "typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true }, "undici-types": { diff --git a/packages/sham-weakref/package.json b/packages/sham-weakref/package.json index 62f6942..173134a 100644 --- a/packages/sham-weakref/package.json +++ b/packages/sham-weakref/package.json @@ -28,7 +28,7 @@ }, "homepage": "https://github.com/denoland/node_deno_shims#readme", "devDependencies": { - "typescript": "^5.2.2", - "ts-node": "^10.9.1" + "typescript": "^5.4.5", + "ts-node": "^10.9.2" } } diff --git a/packages/shim-crypto/package.json b/packages/shim-crypto/package.json index 735cfce..f2fbc64 100644 --- a/packages/shim-crypto/package.json +++ b/packages/shim-crypto/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/denoland/node_deno_shims#readme", "devDependencies": { - "typescript": "^5.2.2", - "ts-node": "^10.9.1" + "typescript": "^5.4.5", + "ts-node": "^10.9.2" } } diff --git a/packages/shim-crypto/src/crypto.types.gen.ts b/packages/shim-crypto/src/crypto.types.gen.ts index 127e5ca..f7cb3a4 100644 --- a/packages/shim-crypto/src/crypto.types.gen.ts +++ b/packages/shim-crypto/src/crypto.types.gen.ts @@ -44,7 +44,9 @@ export interface SubtleCrypto { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */ exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; + exportKey(format: KeyFormat, key: CryptoKey): Promise; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */ + generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: ReadonlyArray<"sign" | "verify">): Promise; generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray): Promise; generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray): Promise; generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise; @@ -172,6 +174,11 @@ export interface RsaOtherPrimesInfo { export type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; +export interface CryptoKeyPair { + privateKey: CryptoKey; + publicKey: CryptoKey; +} + export interface RsaHashedKeyGenParams extends RsaKeyGenParams { hash: HashAlgorithmIdentifier; } @@ -189,11 +196,6 @@ export interface EcKeyGenParams extends Algorithm { export type NamedCurve = string; -export interface CryptoKeyPair { - privateKey: CryptoKey; - publicKey: CryptoKey; -} - export interface AesKeyGenParams extends Algorithm { length: number; } diff --git a/packages/shim-deno-test/package.json b/packages/shim-deno-test/package.json index 2f8809b..3b9de12 100644 --- a/packages/shim-deno-test/package.json +++ b/packages/shim-deno-test/package.json @@ -29,6 +29,6 @@ }, "homepage": "https://github.com/denoland/node_deno_shims#readme", "devDependencies": { - "typescript": "^5.2.2" + "typescript": "^5.4.5" } } diff --git a/packages/shim-deno-test/src/deno.types.gen.d.ts b/packages/shim-deno-test/src/deno.types.gen.d.ts index 4e77388..80d7a28 100644 --- a/packages/shim-deno-test/src/deno.types.gen.d.ts +++ b/packages/shim-deno-test/src/deno.types.gen.d.ts @@ -9,7 +9,7 @@ import { URL } from "url"; * `fn` can be async if required. * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test({ * name: "example test", @@ -49,7 +49,7 @@ export interface DenoTest { * `fn` can be async if required. * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test({ * name: "example test", @@ -86,7 +86,7 @@ export interface DenoTest { * `fn` can be async if required. * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test("My test description", () => { * assertEquals("hello", "hello"); @@ -109,7 +109,7 @@ export interface DenoTest { * `fn` can be async if required. Declared function must have a name. * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test(function myTestName() { * assertEquals("hello", "hello"); @@ -132,7 +132,7 @@ export interface DenoTest { * `fn` can be async if required. * * ```ts - * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts"; + * import { assert, fail, assertEquals } from "jsr:@std/assert"; * * Deno.test("My test description", { permissions: { read: true } }, (): void => { * assertEquals("hello", "hello"); @@ -155,7 +155,7 @@ export interface DenoTest { * `fn` can be async if required. * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test( * { @@ -190,7 +190,7 @@ export interface DenoTest { * `fn` can be async if required. Declared function must have a name. * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test( * { permissions: { read: true } }, @@ -519,7 +519,7 @@ export interface PermissionOptionsObject { * Examples: * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test({ * name: "inherit", @@ -534,7 +534,7 @@ export interface PermissionOptionsObject { * ``` * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test({ * name: "true", @@ -549,7 +549,7 @@ export interface PermissionOptionsObject { * ``` * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test({ * name: "false", @@ -564,7 +564,7 @@ export interface PermissionOptionsObject { * ``` * * ```ts - * import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; + * import { assertEquals } from "jsr:@std/assert"; * * Deno.test({ * name: "localhost:8080", diff --git a/packages/shim-deno/README.md b/packages/shim-deno/README.md index ee086b6..fe904ed 100644 --- a/packages/shim-deno/README.md +++ b/packages/shim-deno/README.md @@ -20,7 +20,7 @@ starting this project and for their contributions—specifically 1. Update local version. 1. In `/.github/workflows/ci.yml`, increase the deno version in the setup-deno action -1. Update version in `./tools/denolib.ts` +1. Update version in `./tools/deno_version.ts` 1. Go into `./third_party/deno` and update the submodule: - `git fetch --tags` - `git checkout v1.x.x` -- replace with version diff --git a/packages/shim-deno/package.json b/packages/shim-deno/package.json index 4244fec..4ff62c1 100644 --- a/packages/shim-deno/package.json +++ b/packages/shim-deno/package.json @@ -48,9 +48,9 @@ "which": "^4.0.0" }, "devDependencies": { - "@types/node": "^20.9.0", - "@types/which": "^3.0.2", - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "@types/node": "^20.12.12", + "@types/which": "^3.0.3", + "ts-node": "^10.9.2", + "typescript": "^5.4.5" } } diff --git a/packages/shim-deno/src/deno/internal/Conn.ts b/packages/shim-deno/src/deno/internal/Conn.ts index 72607ac..66aa3fb 100644 --- a/packages/shim-deno/src/deno/internal/Conn.ts +++ b/packages/shim-deno/src/deno/internal/Conn.ts @@ -3,14 +3,16 @@ import { Socket } from "net"; import { FsFile } from "../stable/classes/FsFile.js"; +import { NetAddr } from "../stable/types.js"; -export class Conn extends FsFile implements Deno.Conn { +export class Conn extends FsFile + implements Deno.Conn { #socket: Socket; constructor( readonly rid: number, - readonly localAddr: Deno.Addr, - readonly remoteAddr: Deno.Addr, + readonly localAddr: A, + readonly remoteAddr: A, socket?: Socket, ) { super(rid); @@ -42,7 +44,7 @@ export class Conn extends FsFile implements Deno.Conn { } } -export class TlsConn extends Conn implements Deno.TlsConn { +export class TlsConn extends Conn implements Deno.TlsConn { handshake(): Promise { console.warn("@deno/shim-deno: Handshake is not supported."); return Promise.resolve({ diff --git a/packages/shim-deno/src/deno/internal/Listener.ts b/packages/shim-deno/src/deno/internal/Listener.ts index 824469a..781a31d 100644 --- a/packages/shim-deno/src/deno/internal/Listener.ts +++ b/packages/shim-deno/src/deno/internal/Listener.ts @@ -1,14 +1,19 @@ /// import { close } from "../stable/functions/close.js"; +import { Addr } from "../stable/types.js"; import * as errors from "../stable/variables/errors.js"; +import { Conn } from "./Conn.js"; -export class Listener implements Deno.Listener { +export class Listener< + TConn extends Deno.Conn = Conn, + A extends Deno.Addr = Addr, +> implements Deno.Listener { #listener: AsyncIterableIterator; constructor( readonly rid: number, - readonly addr: Deno.Addr, + readonly addr: A, listener: AsyncIterableIterator, ) { this.#listener = listener; diff --git a/packages/shim-deno/src/deno/internal/version.ts b/packages/shim-deno/src/deno/internal/version.ts index e962e39..3b779d6 100644 --- a/packages/shim-deno/src/deno/internal/version.ts +++ b/packages/shim-deno/src/deno/internal/version.ts @@ -1,2 +1,2 @@ -export const deno = "1.40.2"; -export const typescript = "5.3.3"; +export const deno = "1.43.3"; +export const typescript = "5.4.5"; diff --git a/packages/shim-deno/src/deno/stable/classes/FsFile.ts b/packages/shim-deno/src/deno/stable/classes/FsFile.ts index 2ff885d..0ac5482 100644 --- a/packages/shim-deno/src/deno/stable/classes/FsFile.ts +++ b/packages/shim-deno/src/deno/stable/classes/FsFile.ts @@ -2,6 +2,7 @@ import * as fs from "fs"; import * as stream from "stream"; +import * as tty from "tty"; import { fstat } from "../functions/fstat.js"; import { fstatSync } from "../functions/fstatSync.js"; import { ftruncate } from "../functions/ftruncate.js"; @@ -119,6 +120,30 @@ export class FsFile implements Deno.FsFile { } return this.#writableStream; } + + isTerminal(): boolean { + return tty.isatty(this.rid); + } + + setRaw(_mode: boolean): void { + throw new Error("Not implemented."); + } + + lock(_exclusive?: boolean | undefined): Promise { + throw new Error("Unstable: Not implemented."); + } + + lockSync(_exclusive?: boolean | undefined): void { + throw new Error("Unstable: Not implemented."); + } + + unlock(): Promise { + throw new Error("Unstable: Not implemented."); + } + + unlockSync(): void { + throw new Error("Unstable: Not implemented."); + } } const File = FsFile; diff --git a/packages/shim-deno/src/deno/stable/functions/connect.ts b/packages/shim-deno/src/deno/stable/functions/connect.ts index d5d0c26..47a334f 100644 --- a/packages/shim-deno/src/deno/stable/functions/connect.ts +++ b/packages/shim-deno/src/deno/stable/functions/connect.ts @@ -2,8 +2,19 @@ import { createConnection } from "net"; import { Conn } from "../../internal/Conn.js"; - -export const connect: typeof Deno.connect = function connect(options) { +import { + ConnectOptions, + NetAddr, + TcpConn, + UnixConn, + UnixConnectOptions, +} from "../types.js"; + +function connect(options: ConnectOptions): Promise; +function connect(options: UnixConnectOptions): Promise; +function connect( + options: ConnectOptions | UnixConnectOptions, +): Promise { if (options.transport === "unix") { throw new Error("Unstable UnixConnectOptions is not implemented"); } @@ -16,7 +27,7 @@ export const connect: typeof Deno.connect = function connect(options) { socket.on("error", (err) => console.error(err)); - return new Promise((resolve) => { + return new Promise>((resolve) => { socket.once("connect", () => { // @ts-expect-error undocumented socket._handle property const rid: number = socket._handle.fd; @@ -38,4 +49,7 @@ export const connect: typeof Deno.connect = function connect(options) { resolve(new Conn(rid, localAddr, remoteAddr, socket)); }); }); -}; +} + +const connectFunc: typeof Deno.connect = connect; +export { connectFunc as connect }; diff --git a/packages/shim-deno/src/deno/stable/functions/listen.ts b/packages/shim-deno/src/deno/stable/functions/listen.ts index 75a2bac..783bcab 100644 --- a/packages/shim-deno/src/deno/stable/functions/listen.ts +++ b/packages/shim-deno/src/deno/stable/functions/listen.ts @@ -4,6 +4,12 @@ import { createServer, Server } from "net"; import { Conn } from "../../internal/Conn.js"; import { Listener } from "../../internal/Listener.js"; +import { + TcpListener, + TcpListenOptions, + UnixListener, + UnixListenOptions, +} from "../types.js"; async function* _listen( server: Server, @@ -39,7 +45,15 @@ async function* _listen( } } -export const listen: typeof Deno.listen = function listen(options) { +function listen(options: TcpListenOptions & { transport?: "tcp" }): TcpListener; +function listen( + options: UnixListenOptions & { transport: "unix" }, +): UnixListener; +function listen( + options: + | TcpListenOptions & { transport?: "tcp" } + | UnixListenOptions & { transport: "unix" }, +): TcpListener | UnixListener { if (options.transport === "unix") { throw new Error("Unstable UnixListenOptions is not implemented"); } @@ -56,11 +70,14 @@ export const listen: typeof Deno.listen = function listen(options) { ); // @ts-expect-error undocumented socket._handle property - const listener = new Listener(server._handle.fd, { + const listener: TcpListener = new Listener(server._handle.fd, { hostname, port, transport: "tcp", }, _listen(server, waitFor)); return listener; -}; +} + +const listenFunc: typeof Deno.listen = listen; +export { listenFunc as listen }; diff --git a/packages/shim-deno/src/deno/stable/functions/listenTls.ts b/packages/shim-deno/src/deno/stable/functions/listenTls.ts index 9bd05af..70060c1 100644 --- a/packages/shim-deno/src/deno/stable/functions/listenTls.ts +++ b/packages/shim-deno/src/deno/stable/functions/listenTls.ts @@ -5,6 +5,7 @@ import { createServer, Server } from "tls"; import { TlsConn } from "../../internal/Conn.js"; import { Listener } from "../../internal/Listener.js"; import { readTextFileSync } from "./readTextFileSync.js"; +import { TlsCertifiedKeyFromFile } from "../types.js"; async function* _listen( server: Server, @@ -40,16 +41,20 @@ async function* _listen( } } -export const listenTls: typeof Deno.listenTls = function listen( - { port, hostname = "0.0.0.0", transport = "tcp", certFile, keyFile }, -) { +export const listenTls: typeof Deno.listenTls = function listenTls({ + port, + hostname = "0.0.0.0", + transport = "tcp", + ...options +}) { if (transport !== "tcp") { throw new Error("Deno.listen is only implemented for transport: tcp"); } - const [cert, key] = [certFile, keyFile].map((f) => - f == null ? undefined : readTextFileSync(f) - ); + const [cert, key] = [ + (options as TlsCertifiedKeyFromFile).certFile, + (options as TlsCertifiedKeyFromFile).keyFile, + ].map((f) => f == null ? undefined : readTextFileSync(f)); const server = createServer({ cert, key }); diff --git a/packages/shim-deno/src/deno/stable/types.ts b/packages/shim-deno/src/deno/stable/types.ts index 20c1270..07698f6 100644 --- a/packages/shim-deno/src/deno/stable/types.ts +++ b/packages/shim-deno/src/deno/stable/types.ts @@ -16,7 +16,8 @@ export type FsEventFlag = Deno.FsEventFlag; export type FsWatcher = Deno.FsWatcher; export type HrtimePermissionDescriptor = Deno.HrtimePermissionDescriptor; export type InspectOptions = Deno.InspectOptions; -export type Listener = Deno.Listener; +export type Listener = + Deno.Listener; export type ListenOptions = Deno.ListenOptions; export type ListenTlsOptions = Deno.ListenTlsOptions; export type MakeTempOptions = Deno.MakeTempOptions; @@ -63,6 +64,9 @@ export type WriteFileOptions = Deno.WriteFileOptions; export type WritePermissionDescriptor = Deno.WritePermissionDescriptor; export type Writer = Deno.Writer; export type WriterSync = Deno.WriterSync; +export type TcpListener = Listener; +export type UnixListener = Listener; +export type TlsCertifiedKeyFromFile = Deno.TlsCertifiedKeyFromFile; export type CAARecord = Deno.CAARecord; export type MXRecord = Deno.MXRecord; diff --git a/packages/shim-deno/third_party/deno b/packages/shim-deno/third_party/deno index 9a55a72..d6ad253 160000 --- a/packages/shim-deno/third_party/deno +++ b/packages/shim-deno/third_party/deno @@ -1 +1 @@ -Subproject commit 9a55a72cf195b2d5cee1e8598c7d28e4b1e8013a +Subproject commit d6ad253882a6c066e0c673ff64e6554a37bb3487 diff --git a/packages/shim-deno/tools/deno_version.ts b/packages/shim-deno/tools/deno_version.ts index a0df580..25355f7 100644 --- a/packages/shim-deno/tools/deno_version.ts +++ b/packages/shim-deno/tools/deno_version.ts @@ -1,7 +1,7 @@ -export const version = "1.40.2"; +export const version = "1.43.3"; export function ensureSpecificDenoVersion() { - if (Deno.version.deno !== "1.40.2") { + if (Deno.version.deno !== "1.43.3") { console.error("Wrong Deno version: " + Deno.version.deno); Deno.exit(1); } diff --git a/packages/shim-deno/tools/denolib.ts b/packages/shim-deno/tools/denolib.ts index 44ef8d7..ca5bc52 100644 --- a/packages/shim-deno/tools/denolib.ts +++ b/packages/shim-deno/tools/denolib.ts @@ -7,9 +7,9 @@ import { ensureSpecificDenoVersion } from "./deno_version.ts"; ensureSpecificDenoVersion(); const stableTypes = await run("deno types"); -const version = (await run("deno --version")).trim().split("\n").map((line) => - line.split(" ") -).reduce( +const version = (await run("deno --version")).trim().split("\n").map(( + line: string, +) => line.split(" ")).reduce( (acc, curr) => ({ ...acc, [curr[0]]: curr[1] }), {} as { [k: string]: string }, ); diff --git a/packages/shim-deno/tools/generateDeclarationFile.ts b/packages/shim-deno/tools/generateDeclarationFile.ts index 52c1f7d..bf73b6a 100644 --- a/packages/shim-deno/tools/generateDeclarationFile.ts +++ b/packages/shim-deno/tools/generateDeclarationFile.ts @@ -93,6 +93,7 @@ statements.push({ // file to it. Save the file then type check. const newProject = new Project({ compilerOptions: { + lib: ["lib.esnext.d.ts"], // limit to only node types types: ["node"], }, diff --git a/packages/shim-prompts/package.json b/packages/shim-prompts/package.json index 379298e..a5f316a 100644 --- a/packages/shim-prompts/package.json +++ b/packages/shim-prompts/package.json @@ -28,7 +28,7 @@ }, "homepage": "https://github.com/denoland/node_deno_shims#readme", "devDependencies": { - "@types/node": "^20.9.0", - "typescript": "^5.2.2" + "@types/node": "^20.12.12", + "typescript": "^5.4.5" } } diff --git a/packages/shim-timers/package.json b/packages/shim-timers/package.json index cff1ebc..627a054 100644 --- a/packages/shim-timers/package.json +++ b/packages/shim-timers/package.json @@ -28,7 +28,7 @@ }, "homepage": "https://github.com/denoland/node_deno_shims#readme", "devDependencies": { - "typescript": "^5.2.2", - "ts-node": "^10.9.1" + "typescript": "^5.4.5", + "ts-node": "^10.9.2" } } diff --git a/scripts/ts_morph.ts b/scripts/ts_morph.ts index 1b69216..6e3eb5e 100644 --- a/scripts/ts_morph.ts +++ b/scripts/ts_morph.ts @@ -1 +1 @@ -export * from "https://deno.land/x/ts_morph@20.0.0/mod.ts"; +export * from "https://deno.land/x/ts_morph@22.0.0/mod.ts";