diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 56153c1ff..5d8f763cd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,7 @@ jobs: fail-fast: false matrix: scala: [2.13.7, 2.12.15] - nodejs: [16.3.0, 14.16.0, 12.21.0, 10.24.0] + nodejs: [16.3.0, 14.16.0, 12.21.0] steps: - uses: actions/checkout@v2.4.0 - uses: olafurpg/setup-scala@v13 diff --git a/README.md b/README.md index c3204abad..a2e077ac0 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,6 @@ Feel free to open issue/send pull request if you find missing module. Add below line to your SBT project. ```sbt -// For Node.js v10 LTS (Will be dropped on 2021-4-30) -libraryDependencies += "net.exoego" %%% "scala-js-nodejs-v10" % "0.14.0" // For Node.js v12 LTS libraryDependencies += "net.exoego" %%% "scala-js-nodejs-v12" % "0.14.0" // For Node.js v14 LTS diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala deleted file mode 100644 index 214938973..000000000 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala +++ /dev/null @@ -1,136 +0,0 @@ -package io.scalajs.nodejs.buffer - -import io.scalajs.nodejs.{TestEnvironment, buffer} - -import scala.scalajs.js -import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, Uint8Array} -import org.scalatest.funspec.AnyFunSpec - -class BufferTest extends AnyFunSpec { - describe("Buffer") { - describe("instance members") { - it("should sort buffers") { - val buf1 = Buffer.from("ABC") - val buf2 = Buffer.from("BCD") - val buf3 = Buffer.from("ABCD") - - assert(buf1.compare(buf1) === 0) - assert(buf1.compare(buf2) === -1) - assert(buf1.compare(buf3) === -1) - assert(buf2.compare(buf1) === 1) - assert(buf2.compare(buf3) === 1) - } - - it("should support iterating entries") { - val buf = Buffer.from("Hello!") - val it = buf.entries() - assert( - // TODO: Use it.toIterator once io.scalajs.colletion.Iterator removed. - js.Iterator.IteratorOps(it).toIterator.toSeq.map(_.toSeq) === Seq( - Seq(0, 72), - Seq(1, 101), - Seq(2, 108), - Seq(3, 108), - Seq(4, 111), - Seq(5, 33) - ) - ) - } - - it("should support buffer property") { - val arrayBuffer = new ArrayBuffer(16) - val buf = Buffer.from(arrayBuffer) - assert(buf.buffer === arrayBuffer) - } - - it("should support byteOffset property") { - import scala.scalajs.js.typedarray.Int8Array - val nodeBuffer = Buffer.from(js.Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) - val typedarray = new Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length) - assert(typedarray.mkString === new Int8Array(js.Array[Byte](0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).mkString) - } - - it("should support byteLength for specific types") { - assert(Buffer.byteLength("\u00bd + \u00bc = \u00be") === 12) - assert(Buffer.byteLength("\u00bd + \u00bc = \u00be", "utf8") === 12) - assert(Buffer.byteLength(Buffer.alloc(12)) === 12) - assert(Buffer.byteLength(new Uint8Array(12)) === 12) - assert(Buffer.byteLength(new DataView(new ArrayBuffer(12))) === 12) - assert(Buffer.byteLength(new ArrayBuffer(12)) === 12) - } - - it("should support fill") { - val otherBuf = Buffer.from("abcdef") - assert(Buffer.alloc(10).fill(otherBuf).toString() === "abcdefabcd") - } - } - - describe("class members") { - it("should support fields") { - assert(Buffer.poolSize > 0) - } - - it("should create buffers from strings") { - val bufA = Buffer.from("Hello ") - val bufB = Buffer.from("World") - val bufC = bufA + bufB - - assert(bufA.toString() === "Hello ") - assert(bufB.toString() === "World") - assert(bufC.byteLength === 11) - } - - it("should create buffers from buffers") { - val buffer = Buffer.from("hello") - assert(Buffer.from(buffer).toString() === "hello") - - val uints = Uint8Array.from(js.Array(72, 101, 108, 108, 111)) - assert(Buffer.from(uints).toString() === "Hello") - } - - it("should support concat") { - val buffers = js.Array(Buffer.from("abc"), Buffer.from("def"), Buffer.from("ghijk")) - assert(Buffer.compare(Buffer.concat(buffers), Buffer.from("abcdefghijk")) === 0) - assert(Buffer.compare(Buffer.concat(buffers, 5), Buffer.from("abcde")) === 0) - - val uints: js.Array[Uint8Array] = js.Array(Buffer.from("abc"), Buffer.from("def"), Buffer.from("ghijk")) - assert(Buffer.compare(Buffer.concat(uints), Buffer.from("abcdefghijk")) === 0) - assert(Buffer.compare(Buffer.concat(uints, 5), Buffer.from("abcde")) === 0) - } - - it("should support isBufrer") { - assert(!Buffer.isBuffer(null)) - assert(!Buffer.isBuffer(js.Object())) - assert(!Buffer.isBuffer(js.Array(1, 2, 3))) - assert(Buffer.isBuffer(Buffer.from("hello"))) - } - - it("should support isEncoding") { - assert(!Buffer.isEncoding(null)) - assert(!Buffer.isEncoding("")) - assert(Buffer.isEncoding("utf8")) - assert(Buffer.isEncoding("UTF-8")) - } - } - - describe("module members") { - it("should support transcode") { - // package object method - assert(buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") === "hello") - assert(buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") === "?") - } - - it("should support fields") { - // package object method - assert(buffer.INSPECT_MAX_BYTES > 0) - assert(buffer.kMaxLength > 0) - } - - it("should support constants") { - // package object method - assert(buffer.constants.MAX_LENGTH > 0) - assert(buffer.constants.MAX_STRING_LENGTH > 0) - } - } - } -} diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala deleted file mode 100644 index 7bea93cef..000000000 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala +++ /dev/null @@ -1,50 +0,0 @@ -package io.scalajs.nodejs.fs - -import org.scalatest.BeforeAndAfterEach - -import scala.concurrent.ExecutionContext -import org.scalatest.funspec.AsyncFunSpec - -class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { - override implicit val executionContext = ExecutionContext.Implicits.global - - private val dir = "x.FsAsyncTest/foo/bar" - - override def afterEach(): Unit = { - Seq( - "x.FsAsyncTest/foo/bar", - "x.FsAsyncTest/foo", - "x.FsAsyncTest" - ).foreach { d => - if (Fs.existsSync(d)) Fs.rmdirSync(d) - } - } - - describe("Fs") { - it("should support recursive-mkdir") { - for { - dirExistsBeforeMkdir <- Fs.existsFuture(dir) - _ <- Fs.mkdirFuture(dir, MkdirOptions(recursive = true)) - dirStat <- Fs.statFuture(dir) - dirExistsAfterMkdir <- Fs.existsFuture(dir) - } yield { - assert(!dirExistsBeforeMkdir) - assert(dirStat.isDirectory()) - assert(dirExistsAfterMkdir) - } - } - - it("should have alias for recursive-mkdir") { - for { - dirExistsBeforeMkdir <- Fs.existsFuture(dir) - _ <- Fs.mkdirRecursiveFuture(dir) - dirStat <- Fs.statFuture(dir) - dirExistsAfterMkdir <- Fs.existsFuture(dir) - } yield { - assert(!dirExistsBeforeMkdir) - assert(dirStat.isDirectory()) - assert(dirExistsAfterMkdir) - } - } - } -} diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala deleted file mode 100644 index 4e94f0be1..000000000 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala +++ /dev/null @@ -1,26 +0,0 @@ -package io.scalajs.nodejs -package fs - -import io.scalajs.nodejs.buffer.Buffer -import io.scalajs.nodejs.url.URL -import org.scalatest.funspec.AnyFunSpec - -class FsClassesTest extends AnyFunSpec { - val dirname = process.Process.cwd() - - describe("ReadStream") { - it("supports constructor(") { - assert(new ReadStream("package.json").readableLength === 0) - assert(new ReadStream(Buffer.from("package.json")) !== null) - assert(new ReadStream(new URL(s"file:///${dirname}/package.json")) !== null) - } - } - - describe("WriteStream") { - it("supports constructor") { - assert(new WriteStream("NO_SUCH_FILE").writableLength === 0) - assert(new WriteStream(Buffer.from("NO_SUCH_FILE")) !== null) - assert(new WriteStream(new URL(s"file:///${dirname}/NO_SUCH_FILE")) !== null) - } - } -} diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/os/OSTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/os/OSTest.scala deleted file mode 100644 index e787c51b0..000000000 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/os/OSTest.scala +++ /dev/null @@ -1,88 +0,0 @@ -package io.scalajs.nodejs.os - -import io.scalajs.nodejs.TestHelper._ -import org.scalatest.funspec.AnyFunSpec - -/** OS Tests - */ -class OSTest extends AnyFunSpec { - describe("OS") { - it("supports arch()") { - assert(OS.arch().nonEmpty) - } - - it("supports constants") { - assert(isDefined(OS.constants)) - } - - it("supports cpus()") { - val cpus = OS.cpus() - assert(isDefined(cpus)) - assert(cpus(0).model.nonEmpty) - assert(cpus(0).speed > 0) - assert(cpus(0).times.user > 0) - } - - it("supports endianness()") { - assert(OS.endianness() === "BE" || OS.endianness() === "LE") - } - - it("supports EOL") { - assert(OS.EOL === "\n" || OS.EOL === "\r\n") - } - - it("supports freemem()") { - assert(OS.freemem() > 0) - } - - it("supports homedir()") { - assert(isDefined(OS.homedir())) - } - - it("supports hostname()") { - assert(isDefined(OS.hostname())) - } - - it("supports loadavg()") { - assert(isDefined(OS.loadavg())) - assert(OS.loadavg().nonEmpty) - } - - it("supports networkInterfaces()") { - val networkInterfaces = OS.networkInterfaces() - assert(isDefined(networkInterfaces)) - networkInterfaces foreach { case (name, iface) => - assert(name.nonEmpty) - assert(iface.nonEmpty) - } - } - - it("supports platform()") { - assert(OS.platform().nonEmpty) - } - - it("supports release()") { - assert(isDefined(OS.release())) - } - - it("supports tmpdir()") { - assert(isDefined(OS.tmpdir())) - } - - it("supports totalmem()") { - assert(isDefined(OS.totalmem())) - } - - it("supports type()") { - assert(isDefined(OS.`type`())) - } - - it("supports uptime()") { - assert(isDefined(OS.uptime())) - } - - it("supports userInfo()") { - assert(isDefined(OS.userInfo())) - } - } -} diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala deleted file mode 100644 index 07b523f4f..000000000 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala +++ /dev/null @@ -1,11 +0,0 @@ -package io.scalajs.nodejs.perf_hooks - -import org.scalatest.funspec.AnyFunSpec - -class PerfHooksTest extends AnyFunSpec { - describe("PerfHook") { - it("constants") { - assert(PerfHooks.constants.NODE_PERFORMANCE_GC_MAJOR === 2) - } - } -} diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/AssertTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/AssertTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/AssertTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/AssertTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/TestHelper.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TestHelper.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/TestHelper.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TestHelper.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala diff --git a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala index 95c0e6299..54317338f 100644 --- a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala +++ b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala @@ -1,10 +1,10 @@ -package io.scalajs.nodejs.buffer +package io.scalajs.nodejs +package buffer import scala.scalajs.js +import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, Uint8Array} import org.scalatest.funspec.AnyFunSpec -/** Buffer Tests - */ class BufferTest extends AnyFunSpec { it("should support writeBigInt64BE, writeBigInt64LE, writeBigInt64BE and writeBigInt64BE") { val buf = Buffer.allocUnsafe(8) @@ -12,4 +12,130 @@ class BufferTest extends AnyFunSpec { buf.writeBigInt64BE(v, 0); assert(Buffer.compare(buf, Buffer.from(js.Array(1, 2, 3, 4, 5, 6, 7, 8))) === 0) } + describe("Buffer") { + describe("instance members") { + it("should sort buffers") { + val buf1 = Buffer.from("ABC") + val buf2 = Buffer.from("BCD") + val buf3 = Buffer.from("ABCD") + + assert(buf1.compare(buf1) === 0) + assert(buf1.compare(buf2) === -1) + assert(buf1.compare(buf3) === -1) + assert(buf2.compare(buf1) === 1) + assert(buf2.compare(buf3) === 1) + } + + it("should support iterating entries") { + val buf = Buffer.from("Hello!") + val it = buf.entries() + assert( + // TODO: Use it.toIterator once io.scalajs.colletion.Iterator removed. + js.Iterator.IteratorOps(it).toIterator.toSeq.map(_.toSeq) === Seq( + Seq(0, 72), + Seq(1, 101), + Seq(2, 108), + Seq(3, 108), + Seq(4, 111), + Seq(5, 33) + ) + ) + } + + it("should support buffer property") { + val arrayBuffer = new ArrayBuffer(16) + val buf = Buffer.from(arrayBuffer) + assert(buf.buffer === arrayBuffer) + } + + it("should support byteOffset property") { + import scala.scalajs.js.typedarray.Int8Array + val nodeBuffer = Buffer.from(js.Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) + val typedarray = new Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length) + assert(typedarray.mkString === new Int8Array(js.Array[Byte](0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).mkString) + } + + it("should support byteLength for specific types") { + assert(Buffer.byteLength("\u00bd + \u00bc = \u00be") === 12) + assert(Buffer.byteLength("\u00bd + \u00bc = \u00be", "utf8") === 12) + assert(Buffer.byteLength(Buffer.alloc(12)) === 12) + assert(Buffer.byteLength(new Uint8Array(12)) === 12) + assert(Buffer.byteLength(new DataView(new ArrayBuffer(12))) === 12) + assert(Buffer.byteLength(new ArrayBuffer(12)) === 12) + } + + it("should support fill") { + val otherBuf = Buffer.from("abcdef") + assert(Buffer.alloc(10).fill(otherBuf).toString() === "abcdefabcd") + } + } + + describe("class members") { + it("should support fields") { + assert(Buffer.poolSize > 0) + } + + it("should create buffers from strings") { + val bufA = Buffer.from("Hello ") + val bufB = Buffer.from("World") + val bufC = bufA + bufB + + assert(bufA.toString() === "Hello ") + assert(bufB.toString() === "World") + assert(bufC.byteLength === 11) + } + + it("should create buffers from buffers") { + val buffer = Buffer.from("hello") + assert(Buffer.from(buffer).toString() === "hello") + + val uints = Uint8Array.from(js.Array(72, 101, 108, 108, 111)) + assert(Buffer.from(uints).toString() === "Hello") + } + + it("should support concat") { + val buffers = js.Array(Buffer.from("abc"), Buffer.from("def"), Buffer.from("ghijk")) + assert(Buffer.compare(Buffer.concat(buffers), Buffer.from("abcdefghijk")) === 0) + assert(Buffer.compare(Buffer.concat(buffers, 5), Buffer.from("abcde")) === 0) + + val uints: js.Array[Uint8Array] = js.Array(Buffer.from("abc"), Buffer.from("def"), Buffer.from("ghijk")) + assert(Buffer.compare(Buffer.concat(uints), Buffer.from("abcdefghijk")) === 0) + assert(Buffer.compare(Buffer.concat(uints, 5), Buffer.from("abcde")) === 0) + } + + it("should support isBufrer") { + assert(!Buffer.isBuffer(null)) + assert(!Buffer.isBuffer(js.Object())) + assert(!Buffer.isBuffer(js.Array(1, 2, 3))) + assert(Buffer.isBuffer(Buffer.from("hello"))) + } + + it("should support isEncoding") { + assert(!Buffer.isEncoding(null)) + assert(!Buffer.isEncoding("")) + assert(Buffer.isEncoding("utf8")) + assert(Buffer.isEncoding("UTF-8")) + } + } + + describe("module members") { + it("should support transcode") { + // package object method + assert(buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") === "hello") + assert(buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") === "?") + } + + it("should support fields") { + // package object method + assert(buffer.INSPECT_MAX_BYTES > 0) + assert(buffer.kMaxLength > 0) + } + + it("should support constants") { + // package object method + assert(buffer.constants.MAX_LENGTH > 0) + assert(buffer.constants.MAX_STRING_LENGTH > 0) + } + } + } } diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala similarity index 81% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala index 235254fca..309655c4b 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala +++ b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala @@ -36,23 +36,6 @@ class CryptoTest extends AnyFunSpec with Matchers { computedHash mustEqual expectedHash } - - it("should be able to encrypt and decrypt text from a private key (AES-256-ctr)") { - val alg = "aes-256-ctr" - val key = "this-is-a-private-key" - val stringToEncrypt = "text-to-encrypt" - - val cipher = Crypto.createCipher(alg, key) - val encrypted = cipher.update(stringToEncrypt, "utf8", "base64") - val finalEncryptedValue = encrypted + cipher.`final`("base64") - - val decipher = Crypto.createDecipher(alg, key) - val decrypted = decipher.update(finalEncryptedValue, "base64", "utf8") - val finalDecryptedValue = decrypted + decipher.`final`("utf8") - - finalEncryptedValue mustNot equal(stringToEncrypt) - finalDecryptedValue must equal(stringToEncrypt) - } } describe("Crypto module") { diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala diff --git a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala index 2aa70b386..e66086266 100644 --- a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala +++ b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala @@ -10,14 +10,13 @@ import scala.scalajs.js.JavaScriptException class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { override implicit val executionContext = ExecutionContext.Implicits.global - private val dir = "x.v12/x.FsAsyncTest/foo/bar" + private val dir = "x.FsAsyncTest/foo/bar" override def afterEach(): Unit = { Seq( - "x.v12/x.FsAsyncTest/foo/bar", - "x.v12/x.FsAsyncTest/foo", - "x.v12/x.FsAsyncTest", - "x.v12" + "x.FsAsyncTest/foo/bar", + "x.FsAsyncTest/foo", + "x.FsAsyncTest" ).foreach { d => if (Fs.existsSync(d)) Fs.rmdirSync(d) } @@ -28,12 +27,12 @@ class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { for { dirExistsBeforeMkdir <- Fs.existsFuture(dir) _ <- Fs.mkdirFuture(dir, MkdirOptions(recursive = true)) - _ <- Fs.writeFileFuture("x.v12/hoge.txt", "foo") - fileStat <- Fs.statFuture("x.v12/hoge.txt") + _ <- Fs.writeFileFuture("x.FsAsyncTest/hoge.txt", "foo") + fileStat <- Fs.statFuture("x.FsAsyncTest/hoge.txt") dirStat <- Fs.statFuture(dir) dirExistsAfterMkdir <- Fs.existsFuture(dir) - _ <- Fs.rmdirFuture("x.v12", RmdirOptions(recursive = true)) - dirExistsAfterRmdir <- Fs.existsFuture("x.v12") + _ <- Fs.rmdirFuture("x.FsAsyncTest", RmdirOptions(recursive = true)) + dirExistsAfterRmdir <- Fs.existsFuture("x.FsAsyncTest") } yield { assert(!dirExistsBeforeMkdir) assert(fileStat.isFile()) @@ -48,8 +47,8 @@ class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { dirExistsBeforeMkdir <- Fs.existsFuture(dir) _ <- Fs.mkdirRecursiveFuture(dir) dirExistsAfterMkdir <- Fs.existsFuture(dir) - _ <- Fs.rmdirRecursiveFuture("x.v12") - dirExistsAfterRmdir <- Fs.existsFuture("x.v12") + _ <- Fs.rmdirRecursiveFuture("x.FsAsyncTest") + dirExistsAfterRmdir <- Fs.existsFuture("x.FsAsyncTest") } yield { assert(!dirExistsBeforeMkdir) assert(dirExistsAfterMkdir) @@ -75,5 +74,30 @@ class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { } } + it("should support recursive-mkdir") { + for { + dirExistsBeforeMkdir <- Fs.existsFuture(dir) + _ <- Fs.mkdirFuture(dir, MkdirOptions(recursive = true)) + dirStat <- Fs.statFuture(dir) + dirExistsAfterMkdir <- Fs.existsFuture(dir) + } yield { + assert(!dirExistsBeforeMkdir) + assert(dirStat.isDirectory()) + assert(dirExistsAfterMkdir) + } + } + + it("should have alias for recursive-mkdir") { + for { + dirExistsBeforeMkdir <- Fs.existsFuture(dir) + _ <- Fs.mkdirRecursiveFuture(dir) + dirStat <- Fs.statFuture(dir) + dirExistsAfterMkdir <- Fs.existsFuture(dir) + } yield { + assert(!dirExistsBeforeMkdir) + assert(dirStat.isDirectory()) + assert(dirExistsAfterMkdir) + } + } } } diff --git a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala index 89c591d97..1524ad894 100644 --- a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala +++ b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala @@ -1,17 +1,24 @@ package io.scalajs.nodejs.fs -import io.scalajs.nodejs.fs +import io.scalajs.nodejs.{fs, process} +import io.scalajs.nodejs.buffer.Buffer +import io.scalajs.nodejs.url.URL import org.scalatest.funspec.AnyFunSpec import scala.scalajs.js.JavaScriptException -/** File System (Fs) Tests - */ class FsClassesTest extends AnyFunSpec { + val dirname = process.Process.cwd() + describe("ReadStream") { it("supports pending added in v11.2.0") { assert(new ReadStream("package.json").pending) } + it("supports constructor(") { + assert(new ReadStream("package.json").readableLength === 0) + assert(new ReadStream(Buffer.from("package.json")) !== null) + assert(new ReadStream(new URL(s"file:///${dirname}/package.json")) !== null) + } } describe("opendir") { @@ -39,4 +46,12 @@ class FsClassesTest extends AnyFunSpec { assert(stats.asInstanceOf[BigIntStats].atimeNs.toString.toLong > 0L) assert(stats.asInstanceOf[BigIntStats].mtimeNs.toString.toLong > 0L) } + + describe("WriteStream") { + it("supports constructor") { + assert(new WriteStream("NO_SUCH_FILE").writableLength === 0) + assert(new WriteStream(Buffer.from("NO_SUCH_FILE")) !== null) + assert(new WriteStream(new URL(s"file:///${dirname}/NO_SUCH_FILE")) !== null) + } + } } diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsV8AsyncTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/net/NetTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/net/NetTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/net/NetTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/net/NetTest.scala diff --git a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/os/OSTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/os/OSTest.scala index 4fa11b69e..355993666 100644 --- a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/os/OSTest.scala +++ b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/os/OSTest.scala @@ -1,13 +1,92 @@ package io.scalajs.nodejs.os -import org.scalatest.funsuite.AnyFunSuite - -class OSTest extends AnyFunSuite { - test("constants") { - assert(OS.constants.dlopen.RTLD_LOCAL.isInstanceOf[Int]) - assert(OS.constants.errno.E2BIG.isInstanceOf[Int]) - assert(OS.constants.priority.PRIORITY_HIGHEST.isInstanceOf[Int]) - assert(OS.constants.signals.SIGABRT.isInstanceOf[Int]) - assert(OS.constants.UV_UDP_REUSEADDR.isInstanceOf[Int]) +import io.scalajs.nodejs.TestHelper._ +import org.scalatest.funspec.AnyFunSpec + +/** OS Tests + */ +class OSTest extends AnyFunSpec { + describe("OS") { + it("supports constants") { + assert(OS.constants.dlopen.RTLD_LOCAL.isInstanceOf[Int]) + assert(OS.constants.errno.E2BIG.isInstanceOf[Int]) + assert(OS.constants.priority.PRIORITY_HIGHEST.isInstanceOf[Int]) + assert(OS.constants.signals.SIGABRT.isInstanceOf[Int]) + assert(OS.constants.UV_UDP_REUSEADDR.isInstanceOf[Int]) + } + + it("supports arch()") { + assert(OS.arch().nonEmpty) + } + + it("supports cpus()") { + val cpus = OS.cpus() + assert(isDefined(cpus)) + assert(cpus(0).model.nonEmpty) + assert(cpus(0).speed > 0) + assert(cpus(0).times.user > 0) + } + + it("supports endianness()") { + assert(OS.endianness() === "BE" || OS.endianness() === "LE") + } + + it("supports EOL") { + assert(OS.EOL === "\n" || OS.EOL === "\r\n") + } + + it("supports freemem()") { + assert(OS.freemem() > 0) + } + + it("supports homedir()") { + assert(isDefined(OS.homedir())) + } + + it("supports hostname()") { + assert(isDefined(OS.hostname())) + } + + it("supports loadavg()") { + assert(isDefined(OS.loadavg())) + assert(OS.loadavg().nonEmpty) + } + + it("supports networkInterfaces()") { + val networkInterfaces = OS.networkInterfaces() + assert(isDefined(networkInterfaces)) + networkInterfaces foreach { case (name, iface) => + assert(name.nonEmpty) + assert(iface.nonEmpty) + } + } + + it("supports platform()") { + assert(OS.platform().nonEmpty) + } + + it("supports release()") { + assert(isDefined(OS.release())) + } + + it("supports tmpdir()") { + assert(isDefined(OS.tmpdir())) + } + + it("supports totalmem()") { + assert(isDefined(OS.totalmem())) + } + + it("supports type()") { + assert(isDefined(OS.`type`())) + } + + it("supports uptime()") { + assert(isDefined(OS.uptime())) + } + + it("supports userInfo()") { + assert(isDefined(OS.userInfo())) + } } } diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/path/PathTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/path/PathTest.scala diff --git a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala index b4486fc82..b33ea9cde 100644 --- a/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala +++ b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala @@ -7,5 +7,8 @@ class PerfHooksTest extends AnyFunSpec { it("monitorEventLoopDelay") { assert(PerfHooks.monitorEventLoopDelay().exceeds === 0) } + it("constants") { + assert(PerfHooks.constants.NODE_PERFORMANCE_GC_MAJOR === 2) + } } } diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/stream/StreamTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/stream/StreamTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/stream/StreamTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/stream/StreamTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/url/URLTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala b/app/nodejs-v12/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala rename to app/nodejs-v12/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/Assert.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/Assert.scala index 248e41e94..733290491 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/Assert.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/Assert.scala @@ -67,9 +67,6 @@ trait Assert extends js.Object { */ def fail(message: js.Error): Unit = js.native - @deprecated("Use assert.fail([message]) or other assert functions instead.", "Node.js v10.0.0") - def fail(actual: js.Any, expected: js.Any, message: String, operator: String): Unit = js.native - /** Throws value if value is truthy. This is useful when testing the error argument in callbacks. * @example * assert.ifError(value) diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala index 77bf74a7d..11b318e85 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala @@ -973,39 +973,26 @@ class Buffer protected () extends Uint8Array( /* dummy to trick constructor */ - /** @see * https://nodejs.org/api/buffer.html#buffer_buf_readbiguint64be_offset */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readBigInt64BE( - offset: Int - ): scalajs.js.BigInt = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readBigInt64BE(): scalajs.js.BigInt = js.native + def readBigInt64BE(offset: Int): scalajs.js.BigInt = js.native + def readBigInt64BE(): scalajs.js.BigInt = js.native /** @see * https://nodejs.org/api/buffer.html#buffer_buf_readbiguint64le_offset */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readBigUInt64LE( - offset: Int - ): scalajs.js.BigInt = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readBigUInt64LE(): scalajs.js.BigInt = - js.native + def readBigUInt64LE(offset: Int): scalajs.js.BigInt = js.native + def readBigUInt64LE(): scalajs.js.BigInt = js.native /** @see * https://nodejs.org/api/buffer.html#buffer_buf_writebigint64be_value_offset */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writeBigInt64BE(value: scalajs.js.BigInt, - offset: Int - ): Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writeBigInt64BE( - value: scalajs.js.BigInt - ): Int = js.native + def writeBigInt64BE(value: scalajs.js.BigInt, offset: Int): Int = js.native + def writeBigInt64BE(value: scalajs.js.BigInt): Int = js.native /** @see * https://nodejs.org/api/buffer.html#buffer_buf_writebigint64le_value_offset */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writeBigInt64LE(value: scalajs.js.BigInt, - offset: Int - ): Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writeBigInt64LE( - value: scalajs.js.BigInt - ): Int = js.native + def writeBigInt64LE(value: scalajs.js.BigInt, offset: Int): Int = js.native + def writeBigInt64LE(value: scalajs.js.BigInt): Int = js.native } @js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala index 4f8a1cd2c..718adb62e 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.cluster -import com.thoughtworks.enableIf import net.exoego.scalajs.types.util.Factory import io.scalajs.nodejs.{GID, UID} @@ -31,7 +30,6 @@ trait ClusterSettings extends js.Object { * * From Node.js v13.2.0, v12.16.0. */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var serialization: js.UndefOr[String] = js.native /** Sets the user identity of the process. (See setuid(2).) */ diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala index 08e0ba3ca..bc45463b3 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala @@ -20,77 +20,18 @@ import scala.scalajs.js.| */ @js.native trait Crypto extends js.Object { - // /////////////////////////////////////////////////////////////////////////////// - // Properties - // /////////////////////////////////////////////////////////////////////////////// - - /** The default encoding to use for functions that can take either strings or buffers. The default value is 'buffer', - * which makes methods default to Buffer objects. - * - * The crypto.DEFAULT_ENCODING mechanism is provided for backwards compatibility with legacy programs that expect - * 'binary' to be the default encoding. - */ - @deprecated("New applications should expect the default to be 'buffer'.", "Node.js v10.0") - val DEFAULT_ENCODING: String = js.native - - /** Property for checking and controlling whether a FIPS compliant crypto provider is currently in use. Setting to - * true requires a FIPS build of Node.js. - */ - @deprecated("Please use crypto.setFips() and crypto.getFips() instead.", "Node.js v10.0") - var fips: Boolean = js.native - // /////////////////////////////////////////////////////////////////////////////// // Methods // /////////////////////////////////////////////////////////////////////////////// - /** Creates and returns a Cipher object that uses the given algorithm and password. - * @param algorithm - * The algorithm is dependent on OpenSSL, examples are 'aes192', etc. On recent OpenSSL releases, openssl - * list-cipher-algorithms will display the available cipher algorithms. - * @param password - * The password is used to derive the cipher key and initialization vector (IV). The value must be either a - * 'binary' encoded string or a Buffer. - * @example - * crypto.createCipher(algorithm, password) - */ - @deprecated("Use crypto.createCipheriv() instead.", "Node.js v10.0") def createCipher(algorithm: String, - password: Buffer - ): Cipher = js.native - @deprecated("Use crypto.createCipheriv() instead.", "Node.js v10.0") def createCipher(algorithm: String, - password: String - ): Cipher = js.native - - def createCipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Cipher = js.native - def createCipheriv(algorithm: String, key: String, iv: BufferLike): Cipher = js.native - def createCipheriv(algorithm: String, key: BufferLike, iv: String, options: TransformOptions): Cipher = js.native - def createCipheriv(algorithm: String, key: BufferLike, iv: BufferLike): Cipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createCipheriv(algorithm: String, key: KeyObject, iv: String, options: TransformOptions): Cipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def createCipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Cipher = js.native + def createCipheriv(algorithm: String, key: String, iv: BufferLike): Cipher = js.native + def createCipheriv(algorithm: String, key: BufferLike, iv: String, options: TransformOptions): Cipher = js.native + def createCipheriv(algorithm: String, key: BufferLike, iv: BufferLike): Cipher = js.native + def createCipheriv(algorithm: String, key: KeyObject, iv: String, options: TransformOptions): Cipher = js.native def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike, options: TransformOptions): Cipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createCipheriv(algorithm: String, key: KeyObject, iv: String): Cipher = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike): Cipher = js.native - - /** Creates and returns a Decipher object that uses the given algorithm and password (key). The implementation of - * crypto.createDecipher() derives keys using the OpenSSL function EVP_BytesToKey with the digest algorithm set to - * MD5, one iteration, and no salt. The lack of salt allows dictionary attacks as the same password always creates - * the same key. The low iteration count and non-cryptographically secure hash algorithm allow passwords to be tested - * very rapidly. - * - * In line with OpenSSL's recommendation to use pbkdf2 instead of EVP_BytesToKey it is recommended that developers - * derive a key and IV on their own using crypto.pbkdf2() and to use crypto.createDecipheriv() to create the Decipher - * object. - * @example - * crypto.createDecipher(algorithm, password) - */ - @deprecated("Use crypto.createDecipheriv() instead.", "Node.js v10.0") def createDecipher(algorithm: String, - password: Buffer - ): Decipher = js.native - @deprecated("Use crypto.createDecipheriv() instead.", "Node.js v10.0") def createDecipher(algorithm: String, - password: String - ): Decipher = js.native + def createCipheriv(algorithm: String, key: KeyObject, iv: String): Cipher = js.native + def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike): Cipher = js.native def createDecipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Decipher = js.native def createDecipheriv(algorithm: String, key: String, iv: BufferLike, options: TransformOptions): Decipher = js.native @@ -143,30 +84,18 @@ trait Crypto extends js.Object { def createHmac(algorithm: String, key: BufferLike, options: TransformOptions): Hmac = js.native def createHmac(algorithm: String, key: String): Hmac = js.native def createHmac(algorithm: String, key: BufferLike): Hmac = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createHmac(algorithm: String, key: KeyObject, options: TransformOptions): Hmac = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createHmac(algorithm: String, key: KeyObject): Hmac = js.native + def createHmac(algorithm: String, key: KeyObject, options: TransformOptions): Hmac = js.native + def createHmac(algorithm: String, key: KeyObject): Hmac = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPrivateKey(key: String): KeyObject = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPrivateKey(key: Buffer): KeyObject = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPrivateKey( - key: CreatePrivateKeyOptions - ): KeyObject = js.native + def createPrivateKey(key: String): KeyObject = js.native + def createPrivateKey(key: Buffer): KeyObject = js.native + def createPrivateKey(key: CreatePrivateKeyOptions): KeyObject = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey(key: String): KeyObject = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey(key: Buffer): KeyObject = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey(key: KeyObject): KeyObject = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey( - key: CreatePublicKeyOptions - ): KeyObject = js.native + def createPublicKey(key: String): KeyObject = js.native + def createPublicKey(key: Buffer): KeyObject = js.native + def createPublicKey(key: KeyObject): KeyObject = js.native + def createPublicKey(key: CreatePublicKeyOptions): KeyObject = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createSecretKey(key: Buffer): KeyObject = js.native /** Creates and returns a Sign object that uses the given algorithm. On recent OpenSSL releases, openssl @@ -276,24 +205,20 @@ trait Crypto extends js.Object { def pbkdf2Sync(password: BufferLike, salt: BufferLike, iterations: Int, keylen: Int, digest: String): Buffer = js.native - def privateDecrypt(privateKey: String, buffer: BufferLike): Buffer = js.native - def privateDecrypt(privateKey: Buffer, buffer: BufferLike): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def privateDecrypt(privateKey: String, buffer: BufferLike): Buffer = js.native + def privateDecrypt(privateKey: Buffer, buffer: BufferLike): Buffer = js.native def privateDecrypt(privateKey: PrivateDecryptKeyObject, buffer: BufferLike): Buffer = js.native - def privateEncrypt(privateKey: String, buffer: BufferLike): Buffer = js.native - def privateEncrypt(privateKey: Buffer, buffer: BufferLike): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def privateEncrypt(privateKey: String, buffer: BufferLike): Buffer = js.native + def privateEncrypt(privateKey: Buffer, buffer: BufferLike): Buffer = js.native def privateEncrypt(privateKey: PrivateEncryptKeyObject, buffer: BufferLike): Buffer = js.native - def publicDecrypt(key: String, buffer: BufferLike): Buffer = js.native - def publicDecrypt(key: Buffer, buffer: BufferLike): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def publicDecrypt(key: String, buffer: BufferLike): Buffer = js.native + def publicDecrypt(key: Buffer, buffer: BufferLike): Buffer = js.native def publicDecrypt(key: PublicDecryptKeyObject, buffer: BufferLike): Buffer = js.native - def publicEncrypt(key: String, buffer: BufferLike): Buffer = js.native - def publicEncrypt(key: Buffer, buffer: BufferLike): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def publicEncrypt(key: String, buffer: BufferLike): Buffer = js.native + def publicEncrypt(key: Buffer, buffer: BufferLike): Buffer = js.native def publicEncrypt(key: PublicEncryptKeyObject, buffer: BufferLike): Buffer = js.native def randomBytes(size: Int): Buffer = js.native @@ -343,13 +268,9 @@ trait Crypto extends js.Object { js.native def randomFill[T <: scala.scalajs.js.typedarray.TypedArray[_, T]](buffer: T, callback: Callback1[T]): T = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def randomInt(max: Int): Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def randomInt(max: Int, callback: Callback1[Int]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def randomInt(min: Int, max: Int): Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def randomInt(max: Int): Int = js.native + def randomInt(max: Int, callback: Callback1[Int]): Unit = js.native + def randomInt(min: Int, max: Int): Int = js.native def randomInt(min: Int, max: Int, callback: Callback1[Int]): Unit = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) @@ -396,49 +317,21 @@ trait Crypto extends js.Object { def setFips(enable: Boolean): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(algorithm: String, - data: BufferLike, - key: String - ): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(algorithm: String, - data: BufferLike, - key: Buffer - ): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(algorithm: String, - data: BufferLike, - key: KeyObject - ): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(data: BufferLike, key: String): Buffer = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(data: BufferLike, key: Buffer): Buffer = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(data: BufferLike, - key: KeyObject - ): Buffer = js.native + def sign(algorithm: String, data: BufferLike, key: String): Buffer = js.native + def sign(algorithm: String, data: BufferLike, key: Buffer): Buffer = js.native + def sign(algorithm: String, data: BufferLike, key: KeyObject): Buffer = js.native + def sign(data: BufferLike, key: String): Buffer = js.native + def sign(data: BufferLike, key: Buffer): Buffer = js.native + def sign(data: BufferLike, key: KeyObject): Buffer = js.native def timingSafeEqual(a: BufferLike, b: BufferLike): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(algorithm: String, - data: BufferLike, - key: String - ): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(algorithm: String, - data: BufferLike, - key: Buffer - ): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(algorithm: String, - data: BufferLike, - key: KeyObject - ): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(data: BufferLike, - key: String - ): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(data: BufferLike, - key: Buffer - ): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(data: BufferLike, - key: KeyObject - ): Boolean = js.native + def verify(algorithm: String, data: BufferLike, key: String): Boolean = js.native + def verify(algorithm: String, data: BufferLike, key: Buffer): Boolean = js.native + def verify(algorithm: String, data: BufferLike, key: KeyObject): Boolean = js.native + def verify(data: BufferLike, key: String): Boolean = js.native + def verify(data: BufferLike, key: Buffer): Boolean = js.native + def verify(data: BufferLike, key: KeyObject): Boolean = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) def checkPrime(candidate: ArrayBuffer | SharedArrayBuffer | TypedArray[_, _] | Buffer | DataView | js.BigInt, diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/KeyObject.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/KeyObject.scala index 6f1fff2c4..e367e7481 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/KeyObject.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/KeyObject.scala @@ -4,12 +4,13 @@ import io.scalajs.nodejs.buffer.Buffer import net.exoego.scalajs.types.util.Factory import scala.scalajs.js +import scala.scalajs.js.annotation.JSImport import scala.scalajs.js.typedarray.{DataView, TypedArray} import scala.scalajs.js.| @js.native -// TODO: Can be exposed as newable class when Node.js v10 dropped -sealed trait KeyObject extends js.Object { +@JSImport("crypto", "KeyObject") +class KeyObject(`type_`: String, handle: js.Object) extends js.Object { def `export`(options: KeyObjectExportOptions): Buffer | String = js.native def `export`(): Buffer = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala index f98f7127c..71ec6ade0 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.crypto -import com.thoughtworks.enableIf import io.scalajs.nodejs.buffer.Buffer import io.scalajs.nodejs.stream.Writable @@ -16,13 +15,11 @@ import scala.scalajs.js */ @js.native sealed trait Sign extends Writable { - def sign(privateKey: String): Buffer = js.native - def sign(privateKey: Buffer): Buffer = js.native - def sign(privateKey: String, outputEncoding: String): String = js.native - def sign(privateKey: Buffer, outputEncoding: String): String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def sign(privateKey: KeyObject): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def sign(privateKey: String): Buffer = js.native + def sign(privateKey: Buffer): Buffer = js.native + def sign(privateKey: String, outputEncoding: String): String = js.native + def sign(privateKey: Buffer, outputEncoding: String): String = js.native + def sign(privateKey: KeyObject): Buffer = js.native def sign(privateKey: KeyObject, outputEncoding: String): String = js.native def update(data: String, inputEncoding: String): Unit = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala index e13877dbd..4f2deb212 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala @@ -42,12 +42,10 @@ trait Verify extends Writable { * @return * true or false depending on the validity of the signature for the data and public key. */ - def verify(obj: String, signature: String, signatureEncoding: String): Boolean = js.native - def verify(obj: Buffer, signature: String, signatureEncoding: String): Boolean = js.native - def verify(obj: String, signature: BufferLike): Boolean = js.native - def verify(obj: Buffer, signature: BufferLike): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def verify(obj: String, signature: String, signatureEncoding: String): Boolean = js.native + def verify(obj: Buffer, signature: String, signatureEncoding: String): Boolean = js.native + def verify(obj: String, signature: BufferLike): Boolean = js.native + def verify(obj: Buffer, signature: BufferLike): Boolean = js.native def verify(obj: KeyObject, signature: String, signatureEncoding: String): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def verify(obj: KeyObject, signature: BufferLike): Boolean = js.native + def verify(obj: KeyObject, signature: BufferLike): Boolean = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/Socket.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/Socket.scala index 7c966ab72..55f76384f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/Socket.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/Socket.scala @@ -32,10 +32,8 @@ class Socket protected () extends IEventEmitter { def addMembership(multicastAddress: String, multicastInterface: String): Unit = js.native def addMembership(multicastAddress: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def addSourceSpecificMembership(sourceAddress: String, groupAddress: String, multicastInterface: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def addSourceSpecificMembership(sourceAddress: String, groupAddress: String): Unit = js.native /** Returns an object containing the address information for a socket. For UDP sockets, this object will contain @@ -83,25 +81,18 @@ class Socket protected () extends IEventEmitter { def close(callback: js.Function): Unit = js.native def close(): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def connect(port: Int, address: String, callback: js.Function0[Any]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def connect(port: Int, address: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def connect(port: Int, callback: js.Function0[Any]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def connect(port: Int): Unit = js.native - - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def connect(port: Int, address: String): Unit = js.native + def connect(port: Int, callback: js.Function0[Any]): Unit = js.native + def connect(port: Int): Unit = js.native + def disconnect(): Unit = js.native def dropMembership(multicastAddress: String, multicastInterface: String): Unit = js.native def dropMembership(multicastAddress: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def dropSourceSpecificMembership(sourceAddress: String, groupAddress: String, multicastInterface: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def dropSourceSpecificMembership(sourceAddress: String, groupAddress: String): Unit = js.native def getRecvBufferSize(): Int = js.native @@ -109,7 +100,6 @@ class Socket protected () extends IEventEmitter { def ref(): this.type = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def remoteAddress(): RemoteAddress = js.native def send(msg: BufferMessage, offset: Int, length: Int, port: Int, address: String, callback: js.Function): Unit = diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/package.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/package.scala index 01fc04737..9c98d9b3a 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/package.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/package.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs -import com.thoughtworks.enableIf import io.scalajs.nodejs.buffer.Buffer import scala.scalajs.js @@ -13,7 +12,6 @@ package object dgram { type BufferMessage = Uint8Array | js.Array[Uint8Array] implicit final class SocketExtensions[T <: Socket](private val instance: T) extends AnyVal { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def onConnect(handler: () => Any): T = instance.on("connect", handler) @inline def onClose(handler: () => Any): T = instance.on("close", handler) diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala index 86bc8ec9b..a6964feef 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala @@ -17,7 +17,6 @@ import scala.scalajs.js.annotation.JSImport @js.native @JSImport("events", "EventEmitter") class EventEmitter() extends IEventEmitter { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def this(options: EventEmitterOptions) = this() } @@ -28,7 +27,6 @@ trait EventEmitterOptions extends js.Object { * * Experimental ! */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var captureRejections: Boolean } @@ -165,24 +163,18 @@ object EventEmitter extends js.Object { * * experimental! */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var captureRejections: Boolean = js.native /** experimental! */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var captureRejectionSymbol: js.Symbol = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def once(emitter: IEventEmitter, eventName: String): js.Promise[js.Array[js.Any]] = js.native // TODO: Return AsyncIterator - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def on(emitter: IEventEmitter, eventName: String): js.Any = js.native // TODO: Return AsyncIterator - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def on(emitter: IEventEmitter, eventName: js.Symbol): js.Any = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var errorMonitor: js.Symbol = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Fs.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Fs.scala index 3fcfb3b16..4f98bfab6 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Fs.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Fs.scala @@ -458,10 +458,8 @@ trait Fs extends js.Object { */ def lchownSync(path: Path, uid: UID, gid: GID): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def lutimes(path: Path, atime: Time, mtime: Time, callback: FsCallback0): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def lutimesSync(path: Path, atime: Time, mtime: Time): Unit = js.native /** Asynchronous link(2). No arguments other than a possible exception are given to the completion callback. @@ -635,7 +633,6 @@ trait Fs extends js.Object { */ def open(path: Path, flags: Flags, callback: FsCallback1[FileDescriptor]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def open(path: Path, callback: FsCallback1[FileDescriptor]): Unit = js.native /** Synchronous version of fs.open(). @@ -653,20 +650,15 @@ trait Fs extends js.Object { def openSync(path: Path, flags: Flags, mode: FileMode): FileDescriptor = js.native def openSync(path: Path, flags: Flags): FileDescriptor = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def openSync(path: Path): FileDescriptor = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def opendir(path: Path, options: OpendirOptions, callback: FsCallback1[Fs.Dir[String] | Fs.Dir[Buffer]]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def opendir(path: Path, callback: FsCallback1[Fs.Dir[String]]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def opendirSync(path: Path, options: OpendirOptions): Fs.Dir[String] | Fs.Dir[Buffer] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def opendirSync(path: Path): Fs.Dir[String] = js.native + def opendirSync(path: Path): Fs.Dir[String] = js.native /** Read data from the file specified by fd. * @param fd @@ -722,14 +714,12 @@ trait Fs extends js.Object { def readSync(fd: FileDescriptor, buffer: BufferLike, offset: Int | Null): Unit = js.native def readSync(fd: FileDescriptor, buffer: BufferLike): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readv(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], position: Int | Null, callback: FsCallback2[Int, js.Array[js.typedarray.ArrayBufferView]] ): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readv(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], callback: FsCallback2[Int, js.Array[js.typedarray.ArrayBufferView]] @@ -951,7 +941,6 @@ trait Fs extends js.Object { * @example * fs.rmdir(path, callback) */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def rmdir(path: Path, options: RmdirOptions, callback: FsCallback0): Unit = js.native /** Synchronous rmdir(2rmdir). @@ -962,7 +951,6 @@ trait Fs extends js.Object { */ def rmdirSync(path: Path): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def rmdirSync(path: Path, options: RmdirOptions): Unit = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) @@ -1317,21 +1305,17 @@ trait Fs extends js.Object { def writeSync(fd: FileDescriptor, data: String, encoding: String): Unit = js.native def writeSync(fd: FileDescriptor, data: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writev(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], position: Int | Null, fsCallback2: FsCallback2[Int, js.Array[js.typedarray.ArrayBufferView]] ): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writev(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], fsCallback2: FsCallback2[Int, js.Array[js.typedarray.ArrayBufferView]] ): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writevSync(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], position: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def writevSync(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView]): Unit = js.native + def writevSync(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView]): Unit = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) def cpSync(src: Path, dest: Path, options: CpOptions): Unit = js.native @@ -1380,7 +1364,6 @@ object Fs extends Fs { def lchown(path: Path, uid: UID, gid: GID): js.Promise[Unit] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def lutimes(path: Path, atime: Time, mtime: Time): js.Promise[Unit] = js.native def link(existingPath: Path, newPath: Path): js.Promise[Unit] = js.native @@ -1399,13 +1382,10 @@ object Fs extends Fs { def open(path: Path, flags: Flags, mode: FileMode): js.Promise[FileHandle] = js.native def open(path: Path, flags: Flags, mode: String): js.Promise[FileHandle] = js.native def open(path: Path, flags: Flags): js.Promise[FileHandle] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def open(path: Path): js.Promise[FileHandle] = js.native + def open(path: Path): js.Promise[FileHandle] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def opendir(path: Path, options: OpendirOptions): js.Promise[Dir[String] | Dir[Buffer]] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def opendir(path: Path): js.Promise[Dir[String]] = js.native + def opendir(path: Path): js.Promise[Dir[String]] = js.native def readdir(path: Path, options: ReaddirOptions): js.Promise[ReaddirArrays2] = js.native def readdir(path: Path, encoding: String): js.Promise[ReaddirArrays] = js.native @@ -1429,8 +1409,7 @@ object Fs extends Fs { def rename(oldPath: Path, newPath: Path): js.Promise[Unit] = js.native - def rmdir(path: Path): js.Promise[Unit] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def rmdir(path: Path): js.Promise[Unit] = js.native def rmdir(path: Path, options: RmdirOptions): js.Promise[Unit] = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) @@ -1517,10 +1496,8 @@ object Fs extends Fs { def writeFile(data: BufferLike, options: FileWriteOptions): js.Promise[Unit] = js.native def writeFile(data: BufferLike): js.Promise[Unit] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writev(buffers: js.Array[js.typedarray.ArrayBufferView], position: Int): js.Promise[Unit] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def writev(buffers: js.Array[js.typedarray.ArrayBufferView]): js.Promise[Unit] = js.native + def writev(buffers: js.Array[js.typedarray.ArrayBufferView]): js.Promise[Unit] = js.native } val promises: FsPromises = js.native @@ -1537,7 +1514,6 @@ object Fs extends Fs { val name: TName = js.native } - @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @js.native trait Dir[T] extends js.Object { def close(): js.Promise[Unit] = js.native @@ -1586,8 +1562,7 @@ trait ReaddirOptions extends js.Object { @Factory trait OpendirOptions extends js.Object { - var encoding: js.UndefOr[String] = js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + var encoding: js.UndefOr[String] = js.undefined var bufferSize: js.UndefOr[Double] = js.undefined } @@ -1653,10 +1628,9 @@ trait RmdirOptions extends js.Object { ) var emfileWait: js.UndefOr[Int] = js.undefined @deprecated("Use maxRetries", "Node.js v13.3.0, v12.16.0") - var maxBusyTries: js.UndefOr[Int] = js.undefined - var maxRetries: js.UndefOr[Int] = js.undefined - var retryDelay: js.UndefOr[Int] = js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + var maxBusyTries: js.UndefOr[Int] = js.undefined + var maxRetries: js.UndefOr[Int] = js.undefined + var retryDelay: js.UndefOr[Int] = js.undefined var recursive: js.UndefOr[Boolean] = js.undefined } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala index 1d6bd01c6..b30ed4613 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala @@ -39,6 +39,5 @@ class ReadStream(path: Path) extends stream.Readable { */ def close(callback: js.Function1[Unit, Any]): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) val pending: Boolean = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Stats.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Stats.scala index 902bfb3c6..3921093e7 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Stats.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/Stats.scala @@ -2,7 +2,6 @@ package io.scalajs.nodejs package fs import com.thoughtworks.enableIf - import scala.scalajs.js @js.native @@ -146,15 +145,11 @@ trait Stats extends IStats[Int, Double] */ @js.native trait BigIntStats extends IStats[js.BigInt, js.BigInt] { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def atimeNs: js.BigInt = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def mtimeNs: js.BigInt = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def ctimeNs: js.BigInt = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def birthtimeNs: js.BigInt = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/package.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/package.scala index 536f3b9ff..65cc6f9a3 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/package.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/package.scala @@ -160,7 +160,6 @@ package object fs { promiseWithError0[FileIOError](instance.link(srcpath, dstpath, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def lutimesFuture(path: Path, atime: Time, mtime: Time): Future[Unit] = { promiseWithError0[FileIOError](instance.lutimes(path, atime, mtime, _)) @@ -226,25 +225,21 @@ package object fs { promiseWithError1[FileIOError, FileDescriptor](instance.open(path, flags, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def openFuture(path: Path): Future[FileDescriptor] = { promiseWithError1[FileIOError, FileDescriptor](instance.open(path, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def opendirFuture(path: Path, options: OpendirOptions): Future[Fs.Dir[String] | Fs.Dir[Buffer]] = { promiseWithError1[FileIOError, Fs.Dir[String] | Fs.Dir[Buffer]](instance.opendir(path, options, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def opendirFuture(path: Path): Future[Fs.Dir[String]] = { promiseWithError1[FileIOError, Fs.Dir[String]](instance.opendir(path, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def readvFuture(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView], @@ -253,7 +248,6 @@ package object fs { promiseWithError2[FileIOError, Int, js.Array[js.typedarray.ArrayBufferView]](Fs.readv(fd, buffers, position, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def readvFuture(fd: FileDescriptor, buffers: js.Array[js.typedarray.ArrayBufferView] @@ -416,12 +410,10 @@ package object fs { @inline def rmdirFuture(path: Path): Future[Unit] = promiseWithError0[FileIOError](instance.rmdir(path, _)) - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def rmdirFuture(path: Path, options: RmdirOptions): Future[Unit] = promiseWithError0[FileIOError](instance.rmdir(path, options, _)) - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def rmdirRecursiveFuture(path: Path, options: RmdirOptions): Future[Unit] = { val recursiveEnabled = js.Object.assign(js.Object(), options).asInstanceOf[RmdirOptions] @@ -438,7 +430,6 @@ package object fs { def rmFuture(path: Path, options: RmOptions): Future[Unit] = promiseWithError0[FileIOError](instance.rm(path, options, _)) - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def rmdirRecursiveFuture(path: Path): Future[Unit] = { promiseWithError0[FileIOError](instance.rmdir(path, RmdirOptions(recursive = true), _)) @@ -548,7 +539,6 @@ package object fs { promiseWithError0[FileIOError](instance.writeFile(file, data, _)) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def writevFuture(fd: FileDescriptor, buffers: js.Array[typedarray.ArrayBufferView], @@ -559,7 +549,6 @@ package object fs { ) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def writevFuture(fd: FileDescriptor, buffers: js.Array[typedarray.ArrayBufferView] @@ -576,7 +565,6 @@ package object fs { * the given [[Fs.Dir]] instance */ implicit final class FsDirExtensions[T](private val instance: Fs.Dir[T]) extends AnyVal { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def readFuture(): Future[Option[Fs.Dirent[T]]] = { promiseWithError1[js.Error, Option[Fs.Dirent[T]]](f => { @@ -586,7 +574,6 @@ package object fs { }) } - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def closeFuture(): Future[Unit] = { promiseWithError0[js.Error](instance.close _) @@ -610,8 +597,7 @@ package object fs { @inline def onChange(listener: (String, js.Any) => Any): T = watcher.on("change", listener) - /** Added in Node.js v10.0.0 - * @see + /** @see * https://nodejs.org/api/fs.html#fs_event_close */ @inline diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Agent.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Agent.scala index 0740b66e4..3f6a7349f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Agent.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Agent.scala @@ -42,7 +42,6 @@ class Agent() extends IEventEmitter { */ var maxSockets: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def maxTotalSockets: Double = js.native /** An object which contains queues of requests that have not yet been assigned to sockets. Do not modify. diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ClientRequest.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ClientRequest.scala index 3faae66db..29e85d879 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ClientRequest.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ClientRequest.scala @@ -29,8 +29,7 @@ import scala.scalajs.js.| @js.native @JSImport("http", "ClientRequest") class ClientRequest extends stream.Writable { - // TODO: Remove Int when dropping Node.js v10 - def aborted: Int | Boolean = js.native + def aborted: Boolean = js.native @deprecated("Use request.socket", "Node.js v13.0.0") def connection: net.Socket = js.native @@ -99,12 +98,10 @@ class ClientRequest extends stream.Writable { def setTimeout(timeout: Int, callback: js.Function): Unit = js.native def setTimeout(timeout: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def reusedSocket: Boolean = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) def getRawHeaderNames(): js.Array[String] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def host: String = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Http.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Http.scala index 6a727bb7f..0a53121e1 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Http.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Http.scala @@ -56,7 +56,6 @@ trait Http extends js.Object { def get(options: RequestOptions): ClientRequest = js.native def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def maxHeaderSize: Int = js.native def request(url: String, options: RequestOptions): Unit = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/IncomingMessage.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/IncomingMessage.scala index ec30738a0..e10a3bfbf 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/IncomingMessage.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/IncomingMessage.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.http -import com.thoughtworks.enableIf import io.scalajs.nodejs.net.Socket import io.scalajs.nodejs.stream @@ -16,7 +15,6 @@ import scala.scalajs.js.annotation.JSImport @js.native @JSImport("http", "IncomingMessage") class IncomingMessage extends stream.Readable { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def aborted: Boolean = js.native def complete: Boolean = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala index 6d4dce7a6..317ddb7ca 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala @@ -115,8 +115,7 @@ trait ServerResponse extends stream.Writable { */ def writeContinue(): Unit = js.native - // Todo: Return this.type when Node.js v10 dropped - def writeHead(statusCode: Int, statusMessage: String, headers: js.Object): Unit = js.native + def writeHead(statusCode: Int, statusMessage: String, headers: js.Object): this.type = js.native def writeHead(statusCode: Int, statusMessage: String, headers: js.Dictionary[_]): Unit = js.native def writeHead(statusCode: Int, statusMessage: String): Unit = js.native def writeHead(statusCode: Int, headers: js.Object): Unit = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2SecureServerOptions.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2SecureServerOptions.scala index 8636cdb50..82eb6420c 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2SecureServerOptions.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2SecureServerOptions.scala @@ -35,12 +35,10 @@ trait Http2SecureServerOptions extends js.Object { js.undefined var ticketKeys: js.UndefOr[Buffer] = js.undefined // Options for net.createServers - var allowHalfOpen: js.UndefOr[Boolean] = js.undefined - var pauseOnConnect: js.UndefOr[Boolean] = js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var maxSessionRejectedStreams: js.UndefOr[Int] = - js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var maxSessionInvalidFrames: js.UndefOr[Int] = - js.undefined + var allowHalfOpen: js.UndefOr[Boolean] = js.undefined + var pauseOnConnect: js.UndefOr[Boolean] = js.undefined + var maxSessionRejectedStreams: js.UndefOr[Int] = js.undefined + var maxSessionInvalidFrames: js.UndefOr[Int] = js.undefined // Options for tls.createSecureContext var ca: js.UndefOr[SecureData] = js.undefined var cert: js.UndefOr[SecureData] = js.undefined diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerOptions.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerOptions.scala index 6bedd3c44..c9ab0df4f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerOptions.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerOptions.scala @@ -24,9 +24,7 @@ trait Http2ServerOptions extends js.Object { var pauseOnConnect: js.UndefOr[Boolean] = js.undefined @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.ltNodeJs14) var selectPadding - : js.UndefOr[js.Function2[Int, Int, Int]] = js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var maxSessionRejectedStreams: js.UndefOr[Int] = - js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var maxSessionInvalidFrames: js.UndefOr[Int] = - js.undefined + : js.UndefOr[js.Function2[Int, Int, Int]] = js.undefined + var maxSessionRejectedStreams: js.UndefOr[Int] = js.undefined + var maxSessionInvalidFrames: js.UndefOr[Int] = js.undefined } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerRequest.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerRequest.scala index 4e35c57be..59909cf9d 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerRequest.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerRequest.scala @@ -12,11 +12,6 @@ import scala.scalajs.js.| class Http2ServerRequest extends stream.Readable with Http2TimeoutOps { def authority: String = js.native - /** Added in Node.js v12.10.0 - * @see - * v12.10.0 - */ - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def complete: Boolean = js.native @deprecated("Use socket", "Node.js v13.0.0") diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala index 5977d00bc..2875c494e 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.http2 -import com.thoughtworks.enableIf import io.scalajs.nodejs.stream import scala.scalajs.js @@ -9,7 +8,6 @@ import scala.scalajs.js trait Http2Stream extends stream.Duplex { def aborted: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def bufferSize: Int = js.native def close(code: Int, callback: js.Function): Unit = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/Server.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/Server.scala index ddfa633e6..30b0fb68b 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/Server.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/Server.scala @@ -1,8 +1,6 @@ package io.scalajs.nodejs package https -import com.thoughtworks.enableIf - import scala.scalajs.js import scala.scalajs.js.annotation.JSImport @@ -11,7 +9,6 @@ import scala.scalajs.js.annotation.JSImport @js.native @JSImport("https", "Server") class Server extends tls.Server { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def headersTimeout: Int = js.native def maxHeaderCount: Int = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/package.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/package.scala index e44e119aa..680696fc3 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/package.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/package.scala @@ -55,7 +55,6 @@ package object https { } implicit final class AgentExtensions[T <: Agent](private val instance: T) extends AnyVal { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def onKeylog(handler: (io.scalajs.nodejs.buffer.Buffer, tls.TLSSocket) => Any): T = instance.on("keylog", handler) } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/module/Module.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/module/Module.scala index a0d490b62..2d944995d 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/module/Module.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/module/Module.scala @@ -14,13 +14,10 @@ object Module extends Module trait Module extends js.Object { var builtinModules: js.Array[String] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createRequire(filename: String): Require = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createRequire(filename: io.scalajs.nodejs.url.URL): Require = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def syncBuiltinESMExports(): Unit = js.native @deprecated("Use createRequire", "Node.js v12.2.0") diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/Socket.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/Socket.scala index 3c1de4ac4..21189d61c 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/Socket.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/Socket.scala @@ -52,7 +52,6 @@ class Socket() extends stream.Duplex with HasHandle { */ def localPort: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def pending: Boolean = js.native /** The string representation of the remote IP address. For example, '74.125.127.100' or '2001:4860:a005::68'. Value diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/package.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/package.scala index e7e3f29c3..3e8cf23fa 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/package.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/package.scala @@ -60,7 +60,6 @@ package object nodejs { def __filename: String = js.Dynamic.global.__filename.asInstanceOf[String] @js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @JSGlobal("queueMicrotask") object queueMicrotask extends js.Function1[js.Function, Unit] { override def apply(arg1: js.Function): Unit = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerfHooks.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerfHooks.scala index fa4698b07..fee9d61d0 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerfHooks.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerfHooks.scala @@ -11,15 +11,12 @@ import scala.scalajs.js.annotation.JSImport trait PerfHooks extends js.Object { def constants: Constants = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def eventLoopUtilization(utilization1: EventLoopUtilizationResult, utilization2: EventLoopUtilizationResult ): EventLoopUtilizationResult = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def monitorEventLoopDelay(): Histogram = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def monitorEventLoopDelay( - options: MonitorEventLoopDelayOptions - ): Histogram = js.native + def monitorEventLoopDelay(): Histogram = js.native + def monitorEventLoopDelay(options: MonitorEventLoopDelayOptions): Histogram = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) def performance: Performance = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/Performance.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/Performance.scala index 0011d4278..800575e94 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/Performance.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/Performance.scala @@ -33,7 +33,6 @@ class Performance extends js.Object { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) def toJSON(): PerformanceResultJson = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def eventLoopUtilization(): EventLoopUtilizationResult = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerformanceObserver.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerformanceObserver.scala index d1a86702f..d1873f087 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerformanceObserver.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerformanceObserver.scala @@ -34,7 +34,6 @@ trait PerformanceObserverEntryList extends js.Object { def monitorEventLoopDelay(options: MonitorEventLoopDelayOptions): Histogram = js.native } -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @js.native trait Histogram extends js.Object { def disable(): Boolean = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Process.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Process.scala index ebbb19446..4dedd2dfb 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Process.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Process.scala @@ -111,10 +111,8 @@ trait Process extends IEventEmitter { */ def release: ReleaseInfo = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def report: js.UndefOr[Reporter] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def resourceUsage(): ResourceUsage = js.native /** process.stderr and process.stdout are unlike other streams in Node.js in that they cannot be closed (end() will @@ -447,7 +445,6 @@ trait HrTime extends js.Function1[js.Array[Int], js.Array[Int]] with js.Function def bigint(): js.BigInt = js.native } -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @js.native trait ResourceUsage extends js.Object { var userCPUTime: Int = js.native @@ -478,9 +475,7 @@ trait Features extends js.Object { val tls_ocsp: Boolean = js.native val tls: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) val inspector: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) val cached_builtins: Boolean = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Reporter.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Reporter.scala index d1fad7704..770274b9a 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Reporter.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Reporter.scala @@ -5,7 +5,6 @@ import com.thoughtworks.enableMembersIf import scala.scalajs.js import scala.scalajs.js.| -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @js.native trait Reporter extends js.Object { def getReport(err: io.scalajs.nodejs.Error): Reporter = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/package.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/package.scala index 51907157b..2ab96527f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/package.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/package.scala @@ -97,7 +97,6 @@ package object process { */ @inline def onUncaughtException(listener: Error => Any): Process = process.on("uncaughtException", listener) - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def onUncaughtException(listener: (Error, String) => Any): Process = process.on("uncaughtException", listener) diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/readline/Interface.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/readline/Interface.scala index 66310a80e..70ef8a406 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/readline/Interface.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/readline/Interface.scala @@ -88,7 +88,6 @@ trait Interface extends IEventEmitter { def cursor: js.UndefOr[Int] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def getCursorPos(): CursorPos = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala index 74ced407a..95283015e 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala @@ -53,7 +53,6 @@ trait REPLServer extends IEventEmitter with Interface { */ def displayPrompt(): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def setupHistory(historyPath: String, callback: js.Function2[io.scalajs.nodejs.Error, REPLServer, Any]): Unit = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/stream/Stream.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/stream/Stream.scala index 61f623dc6..943c44adb 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/stream/Stream.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/stream/Stream.scala @@ -73,10 +73,8 @@ class Readable() extends IReadable { @js.native @JSImport("stream", "Readable") object Readable extends js.Object { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def from(iterable: js.Iterable[_], - options: ReadableOptions - ): Readable = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def from(iterable: js.Iterable[_]): Readable = + def from(iterable: js.Iterable[_], options: ReadableOptions): Readable = js.native + def from(iterable: js.Iterable[_]): Readable = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) @@ -217,13 +215,10 @@ sealed trait IReadable extends Stream with LegacyStream { @JSName("read") def readAsObject(size: Int): js.Any = js.native @JSName("read") def readAsObject(): js.Any = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readable: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readableEncoding: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readableEnded: Boolean = js.native def readableFlowing: Boolean | Null = js.native @@ -232,7 +227,6 @@ sealed trait IReadable extends Stream with LegacyStream { def readableLength: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def readableObjectMode: Boolean = js.native /** This method will cause the readable stream to resume emitting 'data' events. This method will switch the stream @@ -353,23 +347,18 @@ sealed trait IWritable extends Stream with LegacyStream { */ def uncork(): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writable: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writableEnded: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writableCorked: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writableFinished: Boolean = js.native def writableHighWaterMark: Double = js.native def writableLength: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writableObjectMode: Boolean = js.native def write(chunk: Uint8Array, callback: js.Function1[Error, Any]): Boolean = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala index 979b45a96..bb9f60f45 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala @@ -10,7 +10,6 @@ import scala.scalajs.js trait Immediate extends js.Object { def _onImmediate: js.Function = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def hasRef(): Boolean = js.native def ref(): Immediate = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala index ac9259119..ade23bc9d 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala @@ -13,8 +13,7 @@ trait Timeout extends js.Object { * @return * true, if the timeout has already been called */ - def _called: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def _called: Boolean = js.native def hasRef(): Boolean = js.native def refresh(): Timeout = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Server.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Server.scala index b74d3f8bf..302e59005 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Server.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Server.scala @@ -25,7 +25,6 @@ class Server extends net.Server { */ def addContext(hostname: String, context: SecureContextOptions): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def setSecureContext(context: SecureContextOptions): Unit = js.native /** Returns a Buffer instance holding the keys currently used for encryption/decryption of the TLS Session Tickets diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala index b6241ca73..1cecc261f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/TLSSocket.scala @@ -27,12 +27,10 @@ class TLSSocket protected () extends net.Socket { def disableRenegotiation(): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def enableTrace(): Unit = js.native def encrypted: Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def getCertificate(): TLSCertificate = js.native /** Returns an object representing the peer's certificate. The returned object has some properties corresponding to @@ -64,7 +62,6 @@ class TLSSocket protected () extends net.Socket { */ def getSession(): js.UndefOr[Buffer] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def getSharedSigalgs(): js.Array[String] = js.native def getTLSTicket(): Buffer = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Tls.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Tls.scala index 59e5e227b..dd71ef37f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Tls.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Tls.scala @@ -28,15 +28,12 @@ trait Tls extends js.Object { def getCiphers(): js.Array[String] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def rootCertificates: js.Array[String] = js.native def DEFAULT_ECDH_CURVE: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def DEFAULT_MAX_VERSION: String = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def DEFAULT_MIN_VERSION: String = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/package.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/package.scala index 05584761c..43348fd39 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/package.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/package.scala @@ -18,7 +18,6 @@ package object tls { Buffer | TypedArray[_, _] | DataView | js.Array[String] | js.Array[TypedArray[_, _]] | js.Array[DataView] implicit final class ServerExtensions[T <: Server](private val instance: T) extends AnyVal { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def onKeylog(handler: (Buffer, TLSSocket) => Any): T = instance.on("keylog", handler) @inline def onNewSession(handler: (Buffer, Buffer, js.Function0[Unit]) => Any): T = @@ -32,7 +31,6 @@ package object tls { } implicit final class TLSSocketExtensions[T <: TLSSocket](private val instance: T) extends AnyVal { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @inline def onKeylog(handler: (Buffer, TLSSocket) => Any): T = instance.on("keylog", handler) @inline def onOCSPResponse(handler: (Buffer) => Any): T = instance.on("OCSPResponse", handler) diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala index 1a158de6f..fcd408e11 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/WriteStream.scala @@ -27,21 +27,14 @@ class WriteStream(fd: FileDescriptor) extends net.Socket { */ def columns: Int = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def clearLine(dir: Int, callback: js.Function): Boolean = js.native - // TODO: Return value should be boolean when dropping Node.js v10 - def clearLine(dir: Int): Unit = js.native + def clearLine(dir: Int): Boolean = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def clearScreenDown(callback: js.Function): Boolean = js.native - // TODO: Return value should be boolean when dropping Node.js v10 - def clearScreenDown(): Unit = js.native + def clearScreenDown(): Boolean = js.native - // TODO: Return value should be boolean when dropping Node.js v10 - def cursorTo(x: Int): Unit = js.native - // TODO: Return value should be boolean when dropping Node.js v10 - def cursorTo(x: Int, y: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def cursorTo(x: Int): Boolean = js.native + def cursorTo(x: Int, y: Int): Boolean = js.native def cursorTo(x: Int, y: Int, callback: js.Function): Boolean = js.native def getColorDepth(env: io.scalajs.nodejs.process.Environment): Int = js.native @@ -67,8 +60,6 @@ class WriteStream(fd: FileDescriptor) extends net.Socket { */ def rows: Int = js.native - // TODO: Return value should be boolean when dropping Node.js v10 - def moveCursor(dx: Int, dy: Int): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def moveCursor(dx: Int, dy: Int): Boolean = js.native def moveCursor(dx: Int, dy: Int, callback: js.Function): Boolean = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/InspectOptions.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/InspectOptions.scala index 76ba28003..df10c12ea 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/InspectOptions.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/InspectOptions.scala @@ -51,7 +51,6 @@ trait InspectOptions extends js.Object { var sorted: js.UndefOr[Boolean | js.Function2[String, String, Int]] = js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var getters: js.UndefOr[Boolean | String] = js.undefined /** Fot Node.js v14.0.0+ Specifies the maximum number of characters to include when formatting. Set to null or diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/TextEncoder.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/TextEncoder.scala index cdaab757b..d9de15ddd 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/TextEncoder.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/TextEncoder.scala @@ -5,7 +5,6 @@ import scala.scalajs.js.annotation.JSImport import scala.scalajs.js.typedarray.Uint8Array @js.native @JSImport("util", "TextEncoder") -// TODO: The class can be available on the global object when Node.js v10 is drooped class TextEncoder() extends js.Object { def this(encoding: String) = this() diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/V8.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/V8.scala index 66c78bd61..da8606b0c 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/V8.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/V8.scala @@ -13,19 +13,16 @@ trait V8 extends js.Object { def getHeapSpaceStatistics(): js.Array[HeapSpaceStatistics] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def getHeapSnapshot(): io.scalajs.nodejs.stream.Readable = js.native def getHeapStatistics(): HeapStatistics = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def getHeapCodeStatistics(): HeapCodeStatistics = js.native def setFlagsFromString(flags: String): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writeHeapSnapshot(filename: String): String = - js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writeHeapSnapshot(): String = js.native + def writeHeapSnapshot(filename: String): String = js.native + def writeHeapSnapshot(): String = js.native def serialize(value: js.Any): Buffer = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/vm/VM.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/vm/VM.scala index 772dc4ae0..d58b1c3dc 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/vm/VM.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/vm/VM.scala @@ -97,12 +97,10 @@ object VM extends VM @Factory trait CompileFunctionOptions extends js.Object { - var filename: js.UndefOr[String] = js.undefined - var lineOffset: js.UndefOr[Int] = js.undefined - var columnOffset: js.UndefOr[Int] = js.undefined - var cachedData: js.UndefOr[Uint8Array | DataView] = js.undefined - @deprecated("Use script.createCachedData", "Node.js v10") - var produceCachedData: js.UndefOr[Boolean] = js.undefined + var filename: js.UndefOr[String] = js.undefined + var lineOffset: js.UndefOr[Int] = js.undefined + var columnOffset: js.UndefOr[Int] = js.undefined + var cachedData: js.UndefOr[Uint8Array | DataView] = js.undefined var parsingContext: js.UndefOr[js.Object] = js.undefined var contextExtensions: js.UndefOr[js.Array[js.Object]] = js.undefined } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala index 120e50cb5..9aa4f87b9 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala @@ -17,8 +17,7 @@ class Worker protected () extends js.Object with MessagePoster { def ref(): Unit = js.native def unref(): Unit = js.native - // TODO: No need to UnderOr when Node.js v10 dropepd - def terminate(): js.UndefOr[js.Promise[Unit]] = js.native + def terminate(): js.Promise[Unit] = js.native def threadId: Int = js.native @@ -26,13 +25,10 @@ class Worker protected () extends js.Object with MessagePoster { def stdout: io.scalajs.nodejs.stream.Readable = js.native def stdin: io.scalajs.nodejs.stream.Writable | Null = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def resourceLimits: ResourceLimits = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def getHeapSnapshot(): js.Promise[io.scalajs.nodejs.stream.Readable] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def performance: PerformanceObject = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerOptions.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerOptions.scala index 7d6add646..773ea43af 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerOptions.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerOptions.scala @@ -20,6 +20,5 @@ trait WorkerOptions extends js.Object { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) var transferList: js.UndefOr[js.Array[js.Object]] = js.undefined - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) var resourceLimits: js.UndefOr[ResourceLimits] = js.undefined } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala index d480c1992..fc842de80 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala @@ -17,14 +17,11 @@ trait WorkerThreads extends js.Object { def workerData: js.Any = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def moveMessagePortToContext(port: MessagePort, contextifiedSandbox: io.scalajs.nodejs.vm.Context): MessagePort = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def receiveMessageOnPort(port: MessagePort): js.UndefOr[js.Object] = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def resourceLimits: ResourceLimits = js.native } diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Constants.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Constants.scala index 599604313..df0fc3b78 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Constants.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Constants.scala @@ -82,7 +82,6 @@ trait ZlibConstants extends js.Object { val Z_NULL: AllocationType = js.native } -@enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) @js.native trait BlotriConstants extends js.Object { val BROTLI_DECODE: Int = js.native diff --git a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Zlib.scala b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Zlib.scala index dfb30c26b..1a03a260f 100644 --- a/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Zlib.scala +++ b/app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Zlib.scala @@ -13,17 +13,11 @@ import scala.scalajs.js.annotation.JSImport */ @js.native trait Zlib extends js.Object with UncategorizedConstants with ZlibConstants { - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createBrotliCompress( - options: BrotliOptions - ): BrotliCompress = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createBrotliCompress(): BrotliCompress = - js.native + def createBrotliCompress(options: BrotliOptions): BrotliCompress = js.native + def createBrotliCompress(): BrotliCompress = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createBrotliDecompress( - options: BrotliOptions - ): BrotliDecompress = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createBrotliDecompress(): BrotliDecompress = - js.native + def createBrotliDecompress(options: BrotliOptions): BrotliDecompress = js.native + def createBrotliDecompress(): BrotliDecompress = js.native /** Returns a new Deflate object with an options. * @example @@ -77,27 +71,17 @@ trait Zlib extends js.Object with UncategorizedConstants with ZlibConstants { // Convenience Methods // /////////////////////////////////////////////////////////////////////////////// - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def brotliCompress(buffer: Data, options: BrotliOptions, callback: js.Function): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def brotliCompress(buffer: Data, callback: js.Function): Unit = js.native + def brotliCompress(buffer: Data, callback: js.Function): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def brotliCompressSync(buffer: Data, - options: BrotliOptions - ): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def brotliCompressSync(buffer: Data): Buffer = - js.native + def brotliCompressSync(buffer: Data, options: BrotliOptions): Buffer = js.native + def brotliCompressSync(buffer: Data): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def brotliDecompress(buffer: Data, options: BrotliOptions, callback: js.Function): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def brotliDecompress(buffer: Data, callback: js.Function): Unit = js.native + def brotliDecompress(buffer: Data, callback: js.Function): Unit = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def brotliDecompressSync(buffer: Data, - options: BrotliOptions - ): Buffer = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def brotliDecompressSync(buffer: Data): Buffer = - js.native + def brotliDecompressSync(buffer: Data, options: BrotliOptions): Buffer = js.native + def brotliDecompressSync(buffer: Data): Buffer = js.native /** Compress a Buffer or string with Deflate. * @example diff --git a/build.sbt b/build.sbt index 9e5aff8f6..172f3a2a2 100644 --- a/build.sbt +++ b/build.sbt @@ -15,10 +15,9 @@ lazy val root = { name := "scala-js-nodejs" ) val nodejsVersion = Option(System.getenv("NODEJS_VERSION")).filter(_.nonEmpty).getOrElse("") - if (nodejsVersion.startsWith("10.")) p.aggregate(nodejs_v10) - else if (nodejsVersion.startsWith("12.")) p.aggregate(nodejs_v10, nodejs_v12) - else if (nodejsVersion.startsWith("14.")) p.aggregate(nodejs_v10, nodejs_v12, nodejs_v14) - else p.aggregate(nodejs_v10, nodejs_v12, nodejs_v14, nodejs_v16) + if (nodejsVersion.startsWith("12.")) p.aggregate(nodejs_v12) + else if (nodejsVersion.startsWith("14.")) p.aggregate(nodejs_v12, nodejs_v14) + else p.aggregate(nodejs_v12, nodejs_v14, nodejs_v16) } lazy val core = (project in file("./core")) @@ -36,7 +35,7 @@ lazy val nodeVerMap = { try { val nodejsVersionLine = ciYaml.getLines().filter(_.contains("nodejs:")).toSeq.head "\\d+\\.\\d+\\.\\d+".r.findAllIn(nodejsVersionLine).toSeq match { - case Seq(v16, v14, v12, v10) => Map("16" -> v16, "14" -> v14, "12" -> v12, "10" -> v10) + case Seq(v16, v14, v12) => Map("16" -> v16, "14" -> v14, "12" -> v12) } } finally { ciYaml.close() @@ -46,7 +45,6 @@ val latestNodeVersion = "16" lazy val nodejs_v16 = createNodeVersionSpecificProject(nodeVerMap("16")) lazy val nodejs_v14 = createNodeVersionSpecificProject(nodeVerMap("14")) lazy val nodejs_v12 = createNodeVersionSpecificProject(nodeVerMap("12")) -lazy val nodejs_v10 = createNodeVersionSpecificProject(nodeVerMap("10")) def createNodeVersionSpecificProject(nodeFullVersion: String) = { val majorVersion = nodeFullVersion.split("\\.")(0) diff --git a/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala b/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala index de9b2996b..fbcb2ee4e 100644 --- a/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala +++ b/core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala @@ -10,9 +10,6 @@ object CompilerSwitches { predicate(major.toInt, minor.toInt, patch.toInt) } - final val isNodeJs12 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 12)) - final val gteNodeJs12 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 12)) - final val isNodeJs14 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 14)) final val gteNodeJs14 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 14)) final val ltNodeJs14 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major < 14)) diff --git a/script/setup.sh b/script/setup.sh index bff8cf78c..8e9203ace 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,6 +1,15 @@ #!/bin/bash -SOURCE_DIR=$(pwd)/app/nodejs-v14/src/main +SOURCE_DIR=$(pwd)/app/nodejs-v16/src/main + +V14_DIR=$(pwd)/app/nodejs-v14/src/main +if [ -e "$V14_DIR" ]; then + unlink "$V14_DIR" + echo "V14 dir already exists." +else + ln -s "$SOURCE_DIR" "$V14_DIR"; + echo "V14 dir created."; +fi V12_DIR=$(pwd)/app/nodejs-v12/src/main if [ -e "$V12_DIR" ]; then @@ -10,12 +19,3 @@ else ln -s "$SOURCE_DIR" "$V12_DIR"; echo "V12 dir created."; fi - -V10_DIR=$(pwd)/app/nodejs-v10/src/main -if [ -e "$V10_DIR" ]; then - unlink "$V12_DIR" - echo "V10 dir already exists." -else - ln -s "$SOURCE_DIR" "$V10_DIR"; - echo "V10 dir created."; -fi