├── .codecov.yml ├── .git-blame-ignore-revs ├── .github ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── ci.yaml │ ├── format.yml │ ├── release-drafter.yaml │ └── release.yml ├── .gitignore ├── .jvmopts ├── .mergify.yml ├── .scalafmt.conf ├── .tool-version ├── LICENSE ├── README.md ├── app ├── nodejs-v12 │ └── src │ │ └── test │ │ ├── resources │ │ ├── 1.txt │ │ ├── fileA1.txt │ │ ├── fileB1.txt │ │ ├── fileB2.txt │ │ └── watchfile.json │ │ └── scala │ │ └── io │ │ └── scalajs │ │ └── nodejs │ │ ├── AssertTest.scala │ │ ├── StringDecoderTest.scala │ │ ├── TestEnvironment.scala │ │ ├── TestHelper.scala │ │ ├── TopLevelTest.scala │ │ ├── assertion │ │ └── AssertTest.scala │ │ ├── buffer │ │ └── BufferTest.scala │ │ ├── child_process │ │ └── ChildProcessTest.scala │ │ ├── cluster │ │ └── ClusterTest.scala │ │ ├── console_module │ │ ├── ConsoleTest.scala │ │ └── ConsoleV8Test.scala │ │ ├── crypto │ │ ├── CertificateTest.scala │ │ └── CryptoTest.scala │ │ ├── dns │ │ └── DNSTest.scala │ │ ├── events │ │ └── EventEmitterTest.scala │ │ ├── fs │ │ ├── FsAsyncTest.scala │ │ ├── FsClassesTest.scala │ │ ├── FsTest.scala │ │ └── FsV8AsyncTest.scala │ │ ├── http │ │ ├── HttpTest.scala │ │ └── StatusCodeTest.scala │ │ ├── http2 │ │ └── Http2HeadersTest.scala │ │ ├── module │ │ └── ModuleTest.scala │ │ ├── net │ │ └── NetTest.scala │ │ ├── os │ │ └── OSTest.scala │ │ ├── path │ │ └── PathTest.scala │ │ ├── perf_hooks │ │ └── PerfHooksTest.scala │ │ ├── process │ │ ├── EnvironmentTest.scala │ │ └── ProcessTest.scala │ │ ├── querystring │ │ └── QueryStringTest.scala │ │ ├── readline │ │ └── ReadlineTest.scala │ │ ├── stream │ │ ├── ReadableTest.scala │ │ └── StreamTest.scala │ │ ├── tty │ │ └── TTYTest.scala │ │ ├── url │ │ ├── URLObjectTest.scala │ │ ├── URLSearchParamsTest.scala │ │ └── URLTest.scala │ │ ├── util │ │ └── UtilTest.scala │ │ ├── vm │ │ └── VMTest.scala │ │ └── zlib │ │ └── ZlibTest.scala └── nodejs-v16 │ └── src │ ├── main │ └── scala │ │ └── io │ │ └── scalajs │ │ └── nodejs │ │ ├── AbortController.scala │ │ ├── Assert.scala │ │ ├── Error.scala │ │ ├── HasFileDescriptor.scala │ │ ├── HasHandle.scala │ │ ├── Module.scala │ │ ├── Require.scala │ │ ├── StringDecoder.scala │ │ ├── SystemError.scala │ │ ├── buffer │ │ ├── Blob.scala │ │ ├── Buffer.scala │ │ └── package.scala │ │ ├── child_process │ │ ├── ChildProcess.scala │ │ ├── ExecFileSyncOptions.scala │ │ ├── ExecOptions.scala │ │ ├── ForkOptions.scala │ │ ├── SendOptions.scala │ │ ├── SpawnOptions.scala │ │ ├── SpawnSyncOptions.scala │ │ ├── SpawnSyncResult.scala │ │ └── package.scala │ │ ├── cluster │ │ ├── Address.scala │ │ ├── Cluster.scala │ │ ├── ClusterSettings.scala │ │ ├── Worker.scala │ │ └── package.scala │ │ ├── console_module │ │ ├── Console.scala │ │ ├── ConsoleDirOptions.scala │ │ └── ConsoleOptions.scala │ │ ├── crypto │ │ ├── Certificate.scala │ │ ├── Cipher.scala │ │ ├── Crypto.scala │ │ ├── Decipher.scala │ │ ├── DiffieHellman.scala │ │ ├── DiffieHellmanGroup.scala │ │ ├── DiffieHellmanOptions.scala │ │ ├── ECDH.scala │ │ ├── Hash.scala │ │ ├── Hmac.scala │ │ ├── KeyObject.scala │ │ ├── Sign.scala │ │ ├── Verify.scala │ │ ├── X509certificate.scala │ │ └── package.scala │ │ ├── dgram │ │ ├── Dgram.scala │ │ ├── Socket.scala │ │ └── package.scala │ │ ├── dns │ │ ├── DNS.scala │ │ ├── DnsOptions.scala │ │ ├── PromisesResolver.scala │ │ ├── ResolveObject.scala │ │ ├── Resolver.scala │ │ ├── TtlOptions.scala │ │ └── package.scala │ │ ├── events │ │ ├── Event.scala │ │ ├── EventEmitter.scala │ │ └── package.scala │ │ ├── fs │ │ ├── FSConstants.scala │ │ ├── FSWatcher.scala │ │ ├── Fs.scala │ │ ├── ReadStream.scala │ │ ├── Stats.scala │ │ ├── WriteStream.scala │ │ └── package.scala │ │ ├── http │ │ ├── Agent.scala │ │ ├── AgentOptions.scala │ │ ├── Client.scala │ │ ├── ClientRequest.scala │ │ ├── ConnectionOptions.scala │ │ ├── GetNameOptions.scala │ │ ├── Http.scala │ │ ├── IncomingMessage.scala │ │ ├── OutgoingMessage.scala │ │ ├── RequestOptions.scala │ │ ├── Server.scala │ │ ├── ServerOptions.scala │ │ ├── ServerResponse.scala │ │ ├── StatusCodes.scala │ │ └── package.scala │ │ ├── http2 │ │ ├── ClientHttp2Session.scala │ │ ├── ClientHttp2Stream.scala │ │ ├── HasOrigin.scala │ │ ├── Http2.scala │ │ ├── Http2ConnectOptions.scala │ │ ├── Http2Constants.scala │ │ ├── Http2Headers.scala │ │ ├── Http2Priority.scala │ │ ├── Http2PushStreamOptions.scala │ │ ├── Http2RequestOptions.scala │ │ ├── Http2RespondWithFDOptions.scala │ │ ├── Http2RespondWithFileOptions.scala │ │ ├── Http2ResponseOptions.scala │ │ ├── Http2SecureServer.scala │ │ ├── Http2SecureServerOptions.scala │ │ ├── Http2Server.scala │ │ ├── Http2ServerOptions.scala │ │ ├── Http2ServerRequest.scala │ │ ├── Http2ServerResponse.scala │ │ ├── Http2Session.scala │ │ ├── Http2SessionState.scala │ │ ├── Http2Settings.scala │ │ ├── Http2Stream.scala │ │ ├── Http2StreamState.scala │ │ ├── Http2TimeoutOps.scala │ │ ├── ServerHttp2Session.scala │ │ ├── ServerHttp2Stream.scala │ │ └── package.scala │ │ ├── https │ │ ├── Agent.scala │ │ ├── AgentOptions.scala │ │ ├── Https.scala │ │ ├── Server.scala │ │ ├── ServerOptions.scala │ │ └── package.scala │ │ ├── module │ │ ├── Module.scala │ │ └── SourceMap.scala │ │ ├── net │ │ ├── Address.scala │ │ ├── BlockList.scala │ │ ├── ListenerOptions.scala │ │ ├── Net.scala │ │ ├── Server.scala │ │ ├── ServerOptions.scala │ │ ├── Socket.scala │ │ ├── SocketAddress.scala │ │ ├── SocketOptions.scala │ │ └── package.scala │ │ ├── os │ │ ├── CPUInfo.scala │ │ ├── NetworkInterface.scala │ │ ├── OS.scala │ │ ├── OSConstants.scala │ │ ├── UserInfoObject.scala │ │ └── UserInfoOptions.scala │ │ ├── package.scala │ │ ├── path │ │ ├── Path.scala │ │ └── PathObject.scala │ │ ├── perf_hooks │ │ ├── PerfHooks.scala │ │ ├── Performance.scala │ │ └── PerformanceObserver.scala │ │ ├── process │ │ ├── Environment.scala │ │ ├── Process.scala │ │ ├── ProcessConfig.scala │ │ ├── Reporter.scala │ │ └── package.scala │ │ ├── punycode │ │ └── Punycode.scala │ │ ├── querystring │ │ ├── QueryDecodeOptions.scala │ │ ├── QueryEncodeOptions.scala │ │ ├── QueryString.scala │ │ └── package.scala │ │ ├── readline │ │ ├── Interface.scala │ │ ├── Readline.scala │ │ ├── ReadlineOptions.scala │ │ └── package.scala │ │ ├── repl │ │ ├── REPL.scala │ │ ├── REPLServer.scala │ │ └── package.scala │ │ ├── stream │ │ ├── FinishedOptions.scala │ │ ├── LegacyStream.scala │ │ ├── Stream.scala │ │ └── package.scala │ │ ├── timers │ │ ├── ClearImmediate.scala │ │ ├── ClearInterval.scala │ │ ├── ClearTimeout.scala │ │ ├── Immediate.scala │ │ ├── Interval.scala │ │ ├── Ref.scala │ │ ├── SetImmediate.scala │ │ ├── SetInterval.scala │ │ ├── SetTimeout.scala │ │ ├── Timeout.scala │ │ ├── Timer.scala │ │ ├── UnRef.scala │ │ └── package.scala │ │ ├── tls │ │ ├── ConnectOptions.scala │ │ ├── SecureContextOptions.scala │ │ ├── Server.scala │ │ ├── ServerOptions.scala │ │ ├── TLSCertificate.scala │ │ ├── TLSSocket.scala │ │ ├── Tls.scala │ │ └── package.scala │ │ ├── tty │ │ ├── ReadStream.scala │ │ ├── TTY.scala │ │ ├── WriteStream.scala │ │ └── package.scala │ │ ├── url │ │ ├── URL.scala │ │ ├── URLObject.scala │ │ ├── URLSearchParams.scala │ │ └── UrlFormatOptions.scala │ │ ├── util │ │ ├── InspectOptions.scala │ │ ├── TextDecoder.scala │ │ ├── TextEncoder.scala │ │ └── Util.scala │ │ ├── v8 │ │ ├── Deserializer.scala │ │ ├── Serializer.scala │ │ ├── V8.scala │ │ └── package.scala │ │ ├── vm │ │ ├── Script.scala │ │ ├── SyntheticModule.scala │ │ ├── VM.scala │ │ └── package.scala │ │ ├── webstream │ │ └── package.scala │ │ ├── worker_threads │ │ ├── MessageChannel.scala │ │ ├── MessagePort.scala │ │ ├── MessagePoster.scala │ │ ├── ResourceLimits.scala │ │ ├── Worker.scala │ │ ├── WorkerOptions.scala │ │ └── WorkerThreads.scala │ │ └── zlib │ │ ├── BrotliCompress.scala │ │ ├── BrotliDecompress.scala │ │ ├── BrotliOptions.scala │ │ ├── CompressionOptions.scala │ │ ├── Constants.scala │ │ ├── Deflate.scala │ │ ├── DeflateRaw.scala │ │ ├── Gunzip.scala │ │ ├── Gzip.scala │ │ ├── Inflate.scala │ │ ├── InflateRaw.scala │ │ ├── Unzip.scala │ │ ├── Zlib.scala │ │ ├── ZlibBase.scala │ │ └── package.scala │ └── test │ └── scala │ └── io │ └── scalajs │ └── nodejs │ ├── AbortControllerTest.scala │ ├── crypto │ └── CryptoNodeJS14Test.scala │ └── os │ └── NodeJS14Test.scala ├── build.sbt ├── core └── src │ └── main │ └── scala │ └── io │ └── scalajs │ ├── nodejs │ └── internal │ │ └── CompilerSwitches.scala │ └── util │ └── PromiseHelper.scala ├── package.json ├── project ├── Dependencies.scala ├── MySettings.scala ├── build.properties └── plugins.sbt └── script └── setup.sh /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | threshold: 5% 6 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Scala Steward: Reformat with scalafmt 3.7.0 2 | 57d5a2bb48eed7e2cb79b6c7355528e296d66fef 3 | 4 | # Scala Steward: Reformat with scalafmt 3.7.5 5 | b71de66f7a2f7609568ce30c9cc0e0a7919a70af 6 | 7 | # Scala Steward: Reformat with scalafmt 3.8.3 8 | e11d26eafe4be867665da1579d547c40d96f0a30 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "20:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: 'v$NEXT_PATCH_VERSION 🌈' 2 | tag-template: 'v$NEXT_PATCH_VERSION' 3 | categories: 4 | - title: '🚀 Features' 5 | labels: 6 | - 'feature' 7 | - 'enhancement' 8 | - title: '🐛 Bug Fixes' 9 | labels: 10 | - 'fix' 11 | - 'bugfix' 12 | - 'bug' 13 | - title: '👋 deprecation' 14 | labels: 15 | - 'deprecation' 16 | - title: '📚 Docs' 17 | labels: 18 | - 'docs' 19 | - title: '🧰 Maintenance' 20 | labels: 21 | - 'chore' 22 | - 'dependencies' 23 | - 'internal' 24 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 25 | sort-by: 'title' 26 | template: | 27 | ### Remarks 28 | Icon 💥 stands for breaking change. 29 | 30 | $CHANGES 31 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [pull_request] 3 | jobs: 4 | ci: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: false 8 | matrix: 9 | scala: [2.13.8, 2.12.16] 10 | nodejs: [16.16.0, 14.20.0, 12.22.12] 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: olafurpg/setup-scala@v14 14 | with: 15 | java-version: adopt@1.11 16 | - uses: coursier/cache-action@v6 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: ${{ matrix.nodejs }} 20 | - run: npm install 21 | - name: Run Tests 22 | run: sbt ++${{ matrix.scala }} test 23 | env: 24 | NODEJS_VERSION: ${{ matrix.nodejs }} 25 | 26 | -------------------------------------------------------------------------------- /.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [pull_request] 3 | jobs: 4 | format: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: false 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: olafurpg/setup-scala@v14 11 | - name: Check Scalafmt/Scaladoc 12 | run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck nodejs_v14/doc core/doc 13 | - name: Install NPM deps 14 | run: npm install 15 | - name: Check README 16 | run: npm run lint-md 17 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yaml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: release-drafter/release-drafter@v6 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | push: 4 | branches: [master, main] 5 | tags: ["*"] 6 | jobs: 7 | publish: 8 | runs-on: ubuntu-20.04 9 | steps: 10 | - uses: actions/checkout@v4 11 | with: 12 | fetch-depth: 0 13 | - uses: olafurpg/setup-scala@v14 14 | - run: sbt test ci-release 15 | env: 16 | PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} 17 | PGP_SECRET: ${{ secrets.PGP_SECRET }} 18 | SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 19 | SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Scala template 2 | *.class 3 | *.log 4 | 5 | # sbt specific 6 | .cache 7 | .history 8 | .lib/ 9 | dist/* 10 | target/ 11 | lib_managed/ 12 | src_managed/ 13 | project/boot/ 14 | project/plugins/project/ 15 | 16 | # Scala-IDE specific 17 | .scala_dependencies 18 | .worksheet 19 | 20 | # ENSIME specific 21 | .ensime_cache/ 22 | .ensime 23 | 24 | # Ignroe symlinks 25 | app/nodejs-v10/src/main 26 | app/nodejs-v12/src/main 27 | -------------------------------------------------------------------------------- /.jvmopts: -------------------------------------------------------------------------------- 1 | -Xss4M 2 | -Xmx2G 3 | -XX:MaxMetaspaceSize=1G 4 | -XX:+CMSClassUnloadingEnabled 5 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | pull_request_rules: 2 | - name: Automatic merge Scala Steard 3 | conditions: 4 | - "author=scala-steward" 5 | - "#check-success>=8" 6 | actions: 7 | merge: 8 | method: merge 9 | label: 10 | add: ["chore"] 11 | - name: Automatic merge Dependabot 12 | conditions: 13 | - "author~=^dependabot" 14 | - "#check-success>=8" 15 | actions: 16 | merge: 17 | method: merge 18 | label: 19 | add: ["chore"] 20 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = "3.8.3" 2 | runner.dialect = scala213 3 | style = defaultWithAlign 4 | maxColumn = 120 5 | align.openParenDefnSite = true 6 | newlines.afterCurlyLambda = preserve 7 | -------------------------------------------------------------------------------- /.tool-version: -------------------------------------------------------------------------------- 1 | nodejs 16.16.0 2 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/resources/1.txt: -------------------------------------------------------------------------------- 1 | Hello -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/resources/fileA1.txt: -------------------------------------------------------------------------------- 1 | Hello World -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/resources/fileB1.txt: -------------------------------------------------------------------------------- 1 | Goodbye Cruel World -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/resources/fileB2.txt: -------------------------------------------------------------------------------- 1 | Goodbye Cruel World -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/resources/watchfile.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scalajs-io", 3 | "version": "0.4.2", 4 | "private": true, 5 | "dependencies": { 6 | "async": "^2.0.1", 7 | "bcrypt": "^1.0.2", 8 | "bignum": "^0.12.5", 9 | "body-parser": "^1.15.0", 10 | "buffermaker": "^1.2.0", 11 | "cassandra-driver": "^3.0.2", 12 | "cheerio": "^0.22.0", 13 | "colors": "^1.1.2", 14 | "cookie": "^0.3.1", 15 | "cookie-parser": "^1.4.3", 16 | "csv-parse": "^1.1.3", 17 | "drama": "^0.1.3", 18 | "express": "^4.13.4", 19 | "express-csv": "^0.6.0", 20 | "express-ws": "^2.0.0-beta", 21 | "feedparser-promised": "^1.1.1", 22 | "gridfs-stream": "^1.1.1", 23 | "html": "^0.0.10", 24 | "html-to-json": "^0.6.0", 25 | "htmlparser2": "^3.9.2", 26 | "jquery": "^3.1.1", 27 | "jsdom": "^9.9.1", 28 | "jwt-simple": "^0.5.0", 29 | "kafka-node": "^1.3.0", 30 | "kafka-rest": "0.0.4", 31 | "md5": "^2.2.1", 32 | "memory-fs": "^0.3.0", 33 | "moment": "^2.17.1", 34 | "moment-timezone": "^0.5.11", 35 | "mongodb": "^2.1.18", 36 | "mysql": "^2.10.2", 37 | "node-embedded-mongodb": "^0.0.3", 38 | "node-zookeeper-client": "^0.2.2", 39 | "numeral": "^2.0.4", 40 | "oppressor": "0.0.1", 41 | "readline": "^1.3.0", 42 | "rx": "^4.1.0", 43 | "should": "^11.1.2", 44 | "socket.io": "^1.7.2", 45 | "source-map-support": "^0.4.14", 46 | "splitargs": "0.0.7", 47 | "tingodb": "^0.5.1", 48 | "transducers-js": "^0.4.174", 49 | "watch": "^0.18.0", 50 | "xml2js": "^0.4.17" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/AssertTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | /** Assert Test 7 | */ 8 | class AssertTest extends AnyFunSpec { 9 | describe("Assert") { 10 | it("should handle deep comparisons") { 11 | Assert.deepStrictEqual(js.Array(1, 2, 3), js.Array(1, 2, 3)) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class StringDecoderTest extends AnyFunSpec { 7 | describe("StringDecoder") { 8 | it("should decode strings or buffer") { 9 | val decoder = new StringDecoder("utf8") 10 | assert(decoder.write(Buffer.from("Hello ")) === "Hello ") 11 | assert(decoder.write(Buffer.from("World")) === "World") 12 | assert(decoder.end(Buffer.from("!")) === "!") 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | import io.scalajs.nodejs.child_process.ChildProcess 5 | 6 | object TestEnvironment { 7 | private lazy val nodeMajorVersion: Int = 8 | ChildProcess.execSync("node -v").asInstanceOf[Buffer].toString().drop(1).takeWhile(_.isDigit).toInt 9 | 10 | def isWindows: Boolean = os.OS.platform().startsWith("win") 11 | 12 | def isExecutedInExactNode16: Boolean = nodeMajorVersion == 16 13 | def isExecutedInExactNode14: Boolean = nodeMajorVersion == 14 14 | def isExecutedInExactNode12: Boolean = nodeMajorVersion == 12 15 | def isExecutedInExactNode10: Boolean = nodeMajorVersion == 10 16 | 17 | def isExecutedInNode16OrNewer: Boolean = nodeMajorVersion >= 16 18 | def isExecutedInNode14OrNewer: Boolean = nodeMajorVersion >= 14 19 | def isExecutedInNode12OrNewer: Boolean = nodeMajorVersion >= 12 20 | def isExecutedInNode10OrNewer: Boolean = nodeMajorVersion >= 10 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TestHelper.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | object TestHelper { 6 | def isDefined(obj: js.Any): Boolean = obj != null && !js.isUndefined(obj) 7 | } 8 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/TopLevelTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | import org.scalatest.funsuite.AnyFunSuite 5 | 6 | class TopLevelTest extends AnyFunSuite { 7 | test("queueMicrotask") { 8 | assert(queueMicrotask.isInstanceOf[js.Function]) 9 | queueMicrotask(() => println("printed from queueMicrotask")) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.assertion 2 | 3 | import io.scalajs.nodejs.{Assert => NodeAssert} 4 | 5 | import scala.scalajs.js 6 | import org.scalatest.funspec.AnyFunSpec 7 | 8 | class AssertTest extends AnyFunSpec { 9 | it("have strict from v9.9.0") { 10 | assert(NodeAssert.strict !== js.undefined) 11 | } 12 | 13 | it("have rejects/doesNotReject from v10.0.0") { 14 | NodeAssert.strict.rejects(js.Promise.reject("omg")) 15 | NodeAssert.strict.doesNotReject(js.Promise.resolve[String]("wow")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.console_module 2 | 3 | import io.scalajs.nodejs.fs.Fs 4 | import org.scalatest.BeforeAndAfterEach 5 | 6 | import scala.scalajs.js 7 | import org.scalatest.funspec.AnyFunSpec 8 | 9 | class ConsoleTest extends AnyFunSpec with BeforeAndAfterEach { 10 | private val logFileName = "x.nodejs10.ConsoleTest" 11 | 12 | override def afterEach(): Unit = { 13 | if (Fs.existsSync(logFileName)) Fs.unlinkSync(logFileName) 14 | } 15 | 16 | it("should accept no-arguments") { 17 | Console.log() 18 | Console.info() 19 | Console.warn() 20 | Console.debug() 21 | Console.error() 22 | Console.trace() 23 | } 24 | 25 | it("should accept single arguments") { 26 | Console.log("a") 27 | Console.info("a") 28 | Console.warn("a") 29 | Console.debug("a") 30 | Console.error("a") 31 | Console.trace("") 32 | 33 | Console.log(ScalaNativeObject(1)) 34 | Console.info(ScalaNativeObject(1)) 35 | Console.warn(ScalaNativeObject(1)) 36 | Console.debug(ScalaNativeObject(1)) 37 | Console.error(ScalaNativeObject(1)) 38 | Console.trace(ScalaNativeObject(1)) 39 | } 40 | 41 | it("should accept multiple arguments") { 42 | Console.log("a", 1) 43 | Console.info("a", 2) 44 | Console.warn("a", 3) 45 | Console.debug("a", 4) 46 | Console.error(ScalaNativeObject(1), 5) 47 | Console.trace("", ScalaNativeObject(1)) 48 | Console.log("a", 1, ScalaNativeObject(1)) 49 | Console.info("a", 2, ScalaNativeObject(1)) 50 | Console.warn("a", 3, ScalaNativeObject(1)) 51 | Console.debug(ScalaNativeObject(1), "a", 4) 52 | Console.error(ScalaNativeObject(1), "a", 5) 53 | Console.trace(ScalaNativeObject(1), "a", 6) 54 | } 55 | 56 | it("should be passed to foreach") { 57 | val s: Seq[js.Any] = Seq("s", true) 58 | s.foreach(Console.log) 59 | s.foreach(Console.info) 60 | s.foreach(Console.warn) 61 | s.foreach(Console.debug) 62 | s.foreach(Console.error) 63 | s.foreach(Console.trace) 64 | } 65 | 66 | it("have table added in v10.0.0") { 67 | Console.table(js.Array("x", "y")) 68 | } 69 | 70 | it("have timeLog added in v10.7.0") { 71 | val label = "yay" 72 | Console.time(label) 73 | Console.timeLog(label) 74 | Console.timeEnd(label) 75 | } 76 | 77 | it("have constructor(options) added in v10.0.0") { 78 | val console = new Console( 79 | ConsoleOptions( 80 | stdout = io.scalajs.nodejs.process.Process.stdout 81 | ) 82 | ) 83 | 84 | val label = "yay" 85 | console.time(label) 86 | console.timeEnd(label) 87 | } 88 | } 89 | 90 | case class ScalaNativeObject(a: Int, b: Option[Int] = None) 91 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/console_module/ConsoleV8Test.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.console_module 2 | 3 | import io.scalajs.nodejs.TestEnvironment 4 | import io.scalajs.nodejs.fs.{Fs, WriteStream} 5 | import org.scalatest.BeforeAndAfterEach 6 | 7 | import scala.scalajs.js.JavaScriptException 8 | import org.scalatest.funspec.AnyFunSpec 9 | 10 | class ConsoleV8Test extends AnyFunSpec with BeforeAndAfterEach { 11 | private val logFileName = "x.nodejs8.ConsoleTest" 12 | private var failingWritable: WriteStream = null 13 | 14 | override def afterEach(): Unit = { 15 | if (Fs.existsSync(logFileName)) Fs.unlinkSync(logFileName) 16 | } 17 | 18 | override def beforeEach(): Unit = { 19 | failingWritable = Fs.createWriteStream(logFileName) 20 | failingWritable.close(_ => {}) 21 | } 22 | 23 | it("have constructor(stdout, stderr, ignoreErrors) added in v8.0.0") { 24 | val looseConsole = new Console( 25 | stdout = failingWritable, 26 | stderr = failingWritable, 27 | ignoreErrors = true 28 | ) 29 | looseConsole.log("ok") 30 | } 31 | 32 | it("should support ignoreErrors") { 33 | assume(TestEnvironment.isExecutedInNode10OrNewer) 34 | // https://github.com/nodejs/node/issues/33628 35 | assume(TestEnvironment.isExecutedInNode14OrNewer === false) 36 | val strictConsole = new Console( 37 | stdout = failingWritable, 38 | stderr = failingWritable, 39 | ignoreErrors = false 40 | ) 41 | 42 | val ex = intercept[JavaScriptException] { 43 | strictConsole.log("ok") 44 | } 45 | assert(ex.getMessage().contains("write after end")) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | import org.scalatest.funspec.AnyFunSpec 5 | import org.scalatest.matchers.must.Matchers 6 | 7 | class CertificateTest extends AnyFunSpec with Matchers { 8 | val spkacExample = 9 | "MIIBXjCByDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3L0IfUijj7+A8CPC8EmhcdNoe5fUAog7OrBdhn7EkxFButUp40P7+LiYiygYG1TmoI/a5EgsLU3s9twEz3hmgY9mYIqb/rb+SF8qlD/K6KVyUORC7Wlz1Df4L8O3DuRGzx6/+3jIW6cPBpfgH1sVuYS1vDBsP/gMMIxwTsKJ4P0CAwEAARYkYzBkZjFlYjctMTU0NC00MWVkLWFmN2EtZDRkYjBkNDc5ZjZmMA0GCSqGSIb3DQEBBAUAA4GBALEiapUjaIPs5uEdvCP0gFK2qofo+4GpeK1A43mu28lirYPAvCWsmYvKIZIT9TxvzmQIxAfxobf70aSNlSm6MJJKmvurAK+Bpn6ZUKQZ6A1m927LvctVSYJuUi+WVmr0fGE/OfdQ+BqSm/eQ3jnm3fBPVx1uwLPgjC5g4EvGMh8M" 10 | 11 | describe("Certificate object") { 12 | it("exportChallenge") { 13 | assert(Certificate.exportChallenge(spkacExample).toString("utf8") === "c0df1eb7-1544-41ed-af7a-d4db0d479f6f") 14 | } 15 | 16 | it("exportPublicKey") { 17 | assert( 18 | Certificate.exportPublicKey(spkacExample).toString("utf8") === 19 | """-----BEGIN PUBLIC KEY----- 20 | |MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcvQh9SKOPv4DwI8LwSaFx02h7 21 | |l9QCiDs6sF2GfsSTEUG61SnjQ/v4uJiLKBgbVOagj9rkSCwtTez23ATPeGaBj2Zg 22 | |ipv+tv5IXyqUP8ropXJQ5ELtaXPUN/gvw7cO5EbPHr/7eMhbpw8Gl+AfWxW5hLW8 23 | |MGw/+AwwjHBOwong/QIDAQAB 24 | |-----END PUBLIC KEY----- 25 | |""".stripMargin 26 | ) 27 | } 28 | 29 | it("verifySpkac") { 30 | assert(Crypto.Certificate.verifySpkac(Buffer.from("foo")) === false) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.dns 2 | 3 | import org.scalatest.funsuite.AnyFunSuite 4 | 5 | class DNSTest extends AnyFunSuite { 6 | test("getattrinfo codes") { 7 | assert(DNS.ADDRCONFIG.isInstanceOf[Int]) 8 | assert(DNS.V4MAPPED.isInstanceOf[Int]) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.events 2 | 3 | import scala.concurrent.{ExecutionContext, Promise} 4 | import scala.scalajs.js 5 | import org.scalatest.funspec.AsyncFunSpec 6 | 7 | class EventEmitterTest extends AsyncFunSpec { 8 | override implicit val executionContext = ExecutionContext.Implicits.global 9 | 10 | describe("EventEmitter") { 11 | it("should handle custom events with arguments") { 12 | val promise = Promise[js.Array[Int]]() 13 | val myEmitter = new EventEmitter() 14 | myEmitter.on( 15 | "custom-event", 16 | (args: js.Array[Int]) => { 17 | promise.success(args) 18 | } 19 | ) 20 | myEmitter.emit("custom-event", js.Array(1, 2, 3)) 21 | 22 | promise.future.map { array => 23 | assert(array.mkString(",") === "1,2,3") 24 | } 25 | } 26 | 27 | it("should handle one-time events") { 28 | val promise = Promise[Unit]() 29 | val myEmitter = new EventEmitter() 30 | var n = 0 31 | myEmitter.once( 32 | "event", 33 | () => { 34 | n += 1 35 | promise.success(()) 36 | } 37 | ) 38 | myEmitter.emit("event") 39 | myEmitter.emit("event") 40 | 41 | promise.future.map { _ => 42 | assert(n === 1) 43 | } 44 | } 45 | 46 | it("should handle repeated events") { 47 | val promise = Promise[Unit]() 48 | val myEmitter = new EventEmitter() 49 | var n = 0 50 | myEmitter 51 | .on( 52 | "event", 53 | () => { 54 | n += 1 55 | } 56 | ) 57 | .on( 58 | "end", 59 | () => { 60 | promise.success(()) 61 | } 62 | ) 63 | myEmitter.emit("event") 64 | myEmitter.emit("event") 65 | myEmitter.emit("end") 66 | 67 | promise.future.map { _ => 68 | assert(n === 2) 69 | } 70 | } 71 | 72 | it("should count the number of fired events") { 73 | val myEmitter = new EventEmitter() 74 | myEmitter.on("event", () => {}) 75 | myEmitter.on("event", () => {}) 76 | assert(myEmitter.listenerCount("event") === 2) 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/fs/FsClassesTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.fs 2 | 3 | import io.scalajs.nodejs.{fs, process} 4 | import io.scalajs.nodejs.buffer.Buffer 5 | import io.scalajs.nodejs.url.URL 6 | import org.scalatest.funspec.AnyFunSpec 7 | 8 | import scala.scalajs.js.JavaScriptException 9 | 10 | class FsClassesTest extends AnyFunSpec { 11 | val dirname = process.Process.cwd() 12 | 13 | describe("ReadStream") { 14 | it("supports pending added in v11.2.0") { 15 | assert(new ReadStream("package.json").pending) 16 | } 17 | it("supports constructor(") { 18 | assert(new ReadStream("package.json").readableLength === 0) 19 | assert(new ReadStream(Buffer.from("package.json")) !== null) 20 | assert(new ReadStream(new URL(s"file:///${dirname}/package.json")) !== null) 21 | } 22 | } 23 | 24 | describe("opendir") { 25 | it("returns Dir") { 26 | val dir = fs.Fs.opendirSync("core/src") 27 | assert(dir.path === "core/src") 28 | val firstEntry = dir.readSync() 29 | assert(firstEntry.name === "main") 30 | assert(firstEntry.isDirectory()) 31 | 32 | assert(dir.readSync() === null) 33 | 34 | dir.closeSync() 35 | val ex = intercept[JavaScriptException] { 36 | assert(dir.readSync() === null) 37 | } 38 | assert(ex.getMessage().contains("ERR_DIR_CLOSED")) 39 | } 40 | } 41 | 42 | it("adds new members on bigint stats") { 43 | val stats = Fs.statSync("./package.json", StatOptions(bigint = true)).asInstanceOf[BigIntStats] 44 | assert(stats.asInstanceOf[BigIntStats].birthtimeNs.toString.toLong > 0L) 45 | assert(stats.asInstanceOf[BigIntStats].ctimeNs.toString.toLong > 0L) 46 | assert(stats.asInstanceOf[BigIntStats].atimeNs.toString.toLong > 0L) 47 | assert(stats.asInstanceOf[BigIntStats].mtimeNs.toString.toLong > 0L) 48 | } 49 | 50 | describe("WriteStream") { 51 | it("supports constructor") { 52 | assert(new WriteStream("NO_SUCH_FILE").writableLength === 0) 53 | assert(new WriteStream(Buffer.from("NO_SUCH_FILE")) !== null) 54 | assert(new WriteStream(new URL(s"file:///${dirname}/NO_SUCH_FILE")) !== null) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package http 3 | 4 | import scala.scalajs.js 5 | import org.scalatest.funspec.AnyFunSpec 6 | 7 | /** Http Tests 8 | */ 9 | class HttpTest extends AnyFunSpec { 10 | describe("Http") { 11 | it("should provide an HTTP server") { 12 | val server = Http.createServer((request: ClientRequest, response: ServerResponse) => { 13 | response.writeHead(statusCode = 200, headers = js.Dictionary("Content-Type" -> "text/plain")) 14 | response.write("Hello World") 15 | response.end() 16 | }) 17 | assert(server !== null) 18 | 19 | // don't listen on a port 20 | // server.listen(58888) 21 | // setTimeout(() => server.close(), 100.millis) 22 | } 23 | 24 | it("should provide statusCode") { 25 | assert(Http.STATUS_CODES.`403` === "Forbidden") 26 | assert(Http.STATUS_CODES.`500` === "Internal Server Error") 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http/StatusCodeTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import scala.scalajs.js 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | /** Http Tests 7 | */ 8 | class StatusCodeTest extends AnyFunSpec { 9 | describe("Http") { 10 | it("should provide an HTTP server") { 11 | val server = Http.createServer((request: ClientRequest, response: ServerResponse) => { 12 | response.writeHead(statusCode = 200, headers = js.Dictionary("Content-Type" -> "text/plain")) 13 | response.write("Hello World") 14 | response.end() 15 | }) 16 | assert(server !== null) 17 | 18 | // don't listen on a port 19 | // server.listen(58888) 20 | // setTimeout(() => server.close(), 100.millis) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/http2/Http2HeadersTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class Http2HeadersTest extends AnyFunSpec { 7 | describe("Http2Headers") { 8 | it("should treat JS name") { 9 | val headers = Http2Headers.forIncoming( 10 | status = "200", 11 | accessControlMaxAge = "1" 12 | ) 13 | assert(headers.status === "200") 14 | assert(js.JSON.stringify(headers) === """{":status":"200","access-control-max-age":"1"}""") 15 | } 16 | 17 | it("should support user-defined keys") { 18 | val headers = Http2Headers.forIncoming(status = "300") 19 | headers.update("ABC", js.Array("X", "Y", "Z")) 20 | assert(js.JSON.stringify(headers) === """{":status":"300","ABC":["X","Y","Z"]}""") 21 | assert(headers("ABC").toString === "X,Y,Z") 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/module/ModuleTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.module 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | import scala.scalajs.js 6 | 7 | class ModuleTest extends AnyFunSpec { 8 | describe("Module Object (module module)") { 9 | it("builtinModules") { 10 | assert(io.scalajs.nodejs.module.Module.builtinModules.length >= 30) 11 | } 12 | } 13 | 14 | describe("module Object") { 15 | it("children") { 16 | // contents vary on runtime 17 | assert(io.scalajs.nodejs.moduleObject.children.isInstanceOf[js.Array[_]]) 18 | } 19 | it("filename") { 20 | // contents vary on runtime 21 | assert(io.scalajs.nodejs.moduleObject.filename.nonEmpty) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/net/NetTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | /** Network (Net) Tests 6 | */ 7 | class NetTest extends AnyFunSpec { 8 | describe("Net") { 9 | /* 10 | it("provides client-server connectivity") { 11 | val port = 53889 12 | 13 | // startup the server 14 | val server = Net.createServer((socket: Socket) => { 15 | socket.write("Echo server\r\n") 16 | socket.pipe(socket) 17 | }) 18 | 19 | //server.listen(port, "127.0.0.1") 20 | //setTimeout(() => server.close(), 1.second) 21 | 22 | // startup the client 23 | val client = new Socket() 24 | client.connect(port, "127.0.0.1", { () => 25 | console.log("Connected") 26 | client.write("Hello, server! Love, Client.") 27 | }) 28 | 29 | client.onData { data => 30 | console.log("Received: " + data) 31 | client.destroy() // kill client after server"s response 32 | 33 | } onClose { hadError => 34 | console.log("Connection closed: state =>", hadError) 35 | } 36 | } 37 | 38 | it("can provide REPL-like functionality") { 39 | val port = 53888 40 | 41 | val mood = () => { 42 | val m = js.Array("^__^", "-___-", ">.<", "<_>") 43 | m(Math.floor(Math.random() * m.length).toInt) 44 | } 45 | 46 | //A remote node repl that you can telnet to! 47 | val server = Net.createServer((socket: Socket) => { 48 | val remote = REPL.start("node::remote> ", socket) 49 | //Adding "mood" and "bonus" to the remote REPL's context. 50 | remote.context.mood = mood 51 | remote.context.bonus = "UNLOCKED" 52 | }) 53 | 54 | //server.listen(port) 55 | //setTimeout(() => server.close(), 1.second) 56 | 57 | info(s"Remote REPL started on port $port.") 58 | 59 | //A "local" node repl with a custom prompt 60 | val local = REPL.start("node::local> ") 61 | 62 | // Exposing the function "mood" to the local REPL's context. 63 | local.context.mood = mood 64 | }*/ 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/os/OSTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.os 2 | 3 | import io.scalajs.nodejs.TestHelper._ 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | /** OS Tests 7 | */ 8 | class OSTest extends AnyFunSpec { 9 | describe("OS") { 10 | it("supports constants") { 11 | assert(OS.constants.dlopen.RTLD_LOCAL.isInstanceOf[Int]) 12 | assert(OS.constants.errno.E2BIG.isInstanceOf[Int]) 13 | assert(OS.constants.priority.PRIORITY_HIGHEST.isInstanceOf[Int]) 14 | assert(OS.constants.signals.SIGABRT.isInstanceOf[Int]) 15 | assert(OS.constants.UV_UDP_REUSEADDR.isInstanceOf[Int]) 16 | } 17 | 18 | it("supports arch()") { 19 | assert(OS.arch().nonEmpty) 20 | } 21 | 22 | it("supports cpus()") { 23 | val cpus = OS.cpus() 24 | assert(isDefined(cpus)) 25 | assert(cpus(0).model.nonEmpty) 26 | assert(cpus(0).speed > 0) 27 | assert(cpus(0).times.user > 0) 28 | } 29 | 30 | it("supports endianness()") { 31 | assert(OS.endianness() === "BE" || OS.endianness() === "LE") 32 | } 33 | 34 | it("supports EOL") { 35 | assert(OS.EOL === "\n" || OS.EOL === "\r\n") 36 | } 37 | 38 | it("supports freemem()") { 39 | assert(OS.freemem() > 0) 40 | } 41 | 42 | it("supports homedir()") { 43 | assert(isDefined(OS.homedir())) 44 | } 45 | 46 | it("supports hostname()") { 47 | assert(isDefined(OS.hostname())) 48 | } 49 | 50 | it("supports loadavg()") { 51 | assert(isDefined(OS.loadavg())) 52 | assert(OS.loadavg().nonEmpty) 53 | } 54 | 55 | it("supports networkInterfaces()") { 56 | val networkInterfaces = OS.networkInterfaces() 57 | assert(isDefined(networkInterfaces)) 58 | networkInterfaces foreach { case (name, iface) => 59 | assert(name.nonEmpty) 60 | assert(iface.nonEmpty) 61 | } 62 | } 63 | 64 | it("supports platform()") { 65 | assert(OS.platform().nonEmpty) 66 | } 67 | 68 | it("supports release()") { 69 | assert(isDefined(OS.release())) 70 | } 71 | 72 | it("supports tmpdir()") { 73 | assert(isDefined(OS.tmpdir())) 74 | } 75 | 76 | it("supports totalmem()") { 77 | assert(isDefined(OS.totalmem())) 78 | } 79 | 80 | it("supports type()") { 81 | assert(isDefined(OS.`type`())) 82 | } 83 | 84 | it("supports uptime()") { 85 | assert(isDefined(OS.uptime())) 86 | } 87 | 88 | it("supports userInfo()") { 89 | assert(isDefined(OS.userInfo())) 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/path/PathTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package path 3 | 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class PathTest extends AnyFunSpec { 7 | describe("Path") { 8 | it("supports basename()") { 9 | assert(Path.basename("/foo/bar/baz/asdf/quux.html") === "quux.html") 10 | assert(Path.basename("/foo/bar/baz/asdf/quux.html", ".html") === "quux") 11 | } 12 | 13 | it("supports posix.basename()") { 14 | assert(Path.posix.basename("C:\\temp\\data.txt") === "C:\\temp\\data.txt") 15 | assert(Path.posix.basename("/temp/data.txt") === "data.txt") 16 | } 17 | 18 | it("supports win32.basename()") { 19 | assert(Path.win32.basename("C:\\temp\\data.txt") === "data.txt") 20 | assert(Path.win32.basename("/temp/data.txt") === "data.txt") 21 | } 22 | 23 | it("supports format()") { 24 | assert(Path.format(PathObject(root = "/", base = "file.txt")) === "/file.txt") 25 | } 26 | 27 | it("supports isAbsolute()") { 28 | assert(Path.isAbsolute("/foo/bar")) 29 | assert(Path.isAbsolute("/baz/..")) 30 | assert(!Path.isAbsolute("qux/")) 31 | assert(!Path.isAbsolute(".")) 32 | } 33 | 34 | it("supports join()") { 35 | assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") === "/foo/bar/baz/asdf") 36 | } 37 | 38 | it("supports os specific from Node.js v10") { 39 | assert(Path.win32.toNamespacedPath("c:\\foo\\bar") === "\\\\?\\c:\\foo\\bar") 40 | assert(Path.posix.toNamespacedPath("c:\\foo\\bar") === "c:\\foo\\bar") 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/perf_hooks/PerfHooksTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.perf_hooks 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | class PerfHooksTest extends AnyFunSpec { 6 | describe("PerfHook") { 7 | it("monitorEventLoopDelay") { 8 | assert(PerfHooks.monitorEventLoopDelay().exceeds === 0) 9 | } 10 | it("constants") { 11 | assert(PerfHooks.constants.NODE_PERFORMANCE_GC_MAJOR === 2) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/process/EnvironmentTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.process 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | class EnvironmentTest extends AnyFunSpec { 6 | describe("Environment") { 7 | it("have PATH as member") { 8 | assert(Process.env.PATH.nonEmpty) 9 | } 10 | 11 | it("have getter for arbitrary variables") { 12 | assert(Process.env.PATH === Process.env("PATH")) 13 | } 14 | 15 | it("have setter") { 16 | assert(Process.env("__NO_SUCH_ENV_VAR__").isEmpty) 17 | Process.env.update("__NO_SUCH_ENV_VAR__", "FOO") 18 | assert(Process.env("__NO_SUCH_ENV_VAR__").getOrElse("") === "FOO") 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/process/ProcessTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.process 2 | 3 | import io.scalajs.nodejs.os.OS 4 | import io.scalajs.nodejs.TestEnvironment 5 | import org.scalatest.funspec.AnyFunSpec 6 | 7 | class ProcessTest extends AnyFunSpec { 8 | describe("Process") { 9 | val versionPrefix = 10 | if (TestEnvironment.isExecutedInExactNode10) "v10." 11 | else if (TestEnvironment.isExecutedInExactNode12) "v12." 12 | else if (TestEnvironment.isExecutedInExactNode14) "v14." 13 | else if (TestEnvironment.isExecutedInExactNode16) "v16." 14 | else "Unknown node.js version" 15 | 16 | it("contains the following properties") { 17 | assert(Process.arch.isInstanceOf[String]) 18 | assert(Process.argv.length === 1) 19 | assert(Process.argv(0).endsWith("node")) 20 | assert(Process.config.variables.host_arch === OS.arch()) 21 | assert(Process.connected.isEmpty) 22 | assert(Process.cwd().nonEmpty) 23 | assert(Process.env("PATH").nonEmpty) 24 | assert(Process.env.PATH === Process.env("PATH")) 25 | assert(Process.execArgv.length === 0) 26 | assert(Process.execPath.endsWith("node")) 27 | assert(Process.features.uv) 28 | assert(Process.moduleLoadList.length > 0) 29 | assert(Process.title.isInstanceOf[String]) 30 | assert(Process.version.startsWith(versionPrefix)) 31 | assert(s"v${Process.versions.node}".startsWith(versionPrefix)) 32 | 33 | // TODO: actually undefined in test 34 | // assert(process.stdout.isTTY) 35 | // assert(process.stderr.isTTY) 36 | } 37 | 38 | it("hrtime") { 39 | val value = Process.hrtime() 40 | assert(value.length === 2) 41 | val diff = Process.hrtime(value) 42 | assert(diff.length === 2) 43 | assert(diff(0) === 0) 44 | } 45 | 46 | it("hrtime.bigint") { 47 | val value = Process.hrtime.bigint() 48 | assert(value.toString().matches("^\\d+$")) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.querystring 2 | 3 | import io.scalajs.nodejs.querystring.QueryStringTest.MyParams 4 | 5 | import scala.scalajs.js 6 | import org.scalatest.funspec.AnyFunSpec 7 | 8 | /** Query String Test 9 | */ 10 | class QueryStringTest extends AnyFunSpec { 11 | describe("QueryString") { 12 | it("should escape(...)") { 13 | val result = QueryString.escape("""https://www.google.com/#q=node?key=1234""") 14 | assert(result === "https%3A%2F%2Fwww.google.com%2F%23q%3Dnode%3Fkey%3D1234") 15 | } 16 | 17 | it("should parse(...)") { 18 | val result = QueryString.parse("""https://www.google.com/#q=node?key=1234""") 19 | assert(result("https://www.google.com/#q") === "node?key=1234") 20 | assert(result.size === 1) 21 | } 22 | 23 | it("should stringify(...)") { 24 | val result = QueryString.stringify(new MyParams(foo = "1", bar = "2")) 25 | assert(result === "foo=1&bar=2") 26 | } 27 | 28 | it("should unescape(...)") { 29 | val result = QueryString.unescape("https%3A%2F%2Fwww.google.com%2F%23q%3Dnode%3Fkey%3D1234") 30 | assert(result === """https://www.google.com/#q=node?key=1234""") 31 | } 32 | } 33 | 34 | describe("QueryStringEnrichment") { 35 | it("parseAs") { 36 | val result: MyParams = QueryString.parseAs("foo=1&bar=2") 37 | assert(result.foo === "1") 38 | assert(result.bar === "2") 39 | } 40 | } 41 | } 42 | 43 | /** Query String Test Companion 44 | */ 45 | object QueryStringTest { 46 | class MyParams(val foo: String, val bar: String) extends js.Object 47 | } 48 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.readline 2 | 3 | import io.scalajs.nodejs.fs.Fs 4 | import io.scalajs.nodejs.process.Process 5 | 6 | import scala.concurrent.{ExecutionContext, Promise} 7 | import org.scalatest.funspec.AsyncFunSpec 8 | 9 | /** Readline Tests 10 | */ 11 | class ReadlineTest extends AsyncFunSpec { 12 | override implicit val executionContext = ExecutionContext.Implicits.global 13 | 14 | describe("Readline") { 15 | it("should read/stream files from disk") { 16 | val promise = Promise[Unit]() 17 | var lineNo = 0 18 | val file = "./package.json" 19 | val reader = Readline.createInterface( 20 | ReadlineOptions( 21 | input = Fs.createReadStream(file), 22 | output = Process.stdout, 23 | terminal = false 24 | ) 25 | ) 26 | 27 | reader.onLine { line => 28 | lineNo += 1 29 | } 30 | 31 | reader.onClose { () => 32 | promise.success(()) 33 | } 34 | promise.future.map(_ => assert(lineNo === 19)) 35 | } 36 | 37 | it("has REPL-like functionality") { 38 | val promise = Promise[Unit]() 39 | val rl = Readline.createInterface(ReadlineOptions(input = Process.stdin, output = Process.stdout)) 40 | rl.setPrompt("OHAI> ") 41 | rl.prompt() 42 | 43 | rl.onClose { () => 44 | promise.success(()) 45 | } 46 | rl.close() 47 | promise.future.map(_ => succeed) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/stream/ReadableTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.stream 2 | 3 | import io.scalajs.nodejs.fs.ReadStream 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class ReadableTest extends AnyFunSpec { 7 | describe("Readable") { 8 | it("readableEncoding") { 9 | assert(new ReadStream("package.json").readableEncoding === null) 10 | } 11 | 12 | it("readableFlowing") { 13 | val rs = new ReadStream("package.json") 14 | assert(rs.readableFlowing === null) 15 | rs.on("readable", () => {}) 16 | assert(rs.readableFlowing === false) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/stream/StreamTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.stream 2 | 3 | import io.scalajs.nodejs.fs 4 | import io.scalajs.nodejs.fs.Fs 5 | import io.scalajs.nodejs.zlib 6 | import org.scalatest.BeforeAndAfterEach 7 | import org.scalatest.funspec.AnyFunSpec 8 | 9 | import scala.scalajs.js 10 | 11 | class StreamTest extends AnyFunSpec with BeforeAndAfterEach { 12 | override def afterEach(): Unit = { 13 | Seq( 14 | "package.json.gz" 15 | ).foreach { d => 16 | if (Fs.existsSync(d)) Fs.unlinkSync(d) 17 | } 18 | } 19 | 20 | describe("Stream") { 21 | it("pipeline should return the stream which have same type of destination") { 22 | val result = Stream.pipeline( 23 | fs.Fs.createReadStream("package.json"), 24 | zlib.Zlib.createGzip(), 25 | fs.Fs.createWriteStream("package.json.gz"), 26 | err => { 27 | assert(err === js.undefined) 28 | } 29 | ) 30 | assert(result.isInstanceOf[Writable]) 31 | } 32 | } 33 | 34 | describe("StreamModuleExtensions") { 35 | it("pipelineFromSeq should return the stream which have same type of destination") { 36 | val result = Stream.pipelineFromSeq( 37 | fs.Fs.createReadStream("package.json"), 38 | Seq(zlib.Zlib.createGzip()), 39 | fs.Fs.createWriteStream("package.json.gz"), 40 | err => { 41 | assert(err === js.undefined) 42 | } 43 | ) 44 | assert(result.isInstanceOf[Writable]) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.tty 2 | 3 | import org.scalatest.funspec.AnyFunSpec 4 | 5 | /** TTY Test 6 | */ 7 | class TTYTest extends AnyFunSpec { 8 | describe("TTY") { 9 | it("should identify TTY devices") { 10 | // this is freaky, just testing it returns boolean 11 | assert(TTY.isatty(1) || true) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package url 3 | 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | import scala.scalajs.js 7 | 8 | /** URLObject Tests 9 | */ 10 | class URLObjectTest extends AnyFunSpec { 11 | describe("URLObject") { 12 | val originalUrl = "https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node" 13 | val urlObject = new URL(originalUrl) 14 | 15 | it("should break down URLs into components") { 16 | assert( 17 | js.JSON.stringify( 18 | urlObject 19 | ) === "\"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node\"" 20 | ) 21 | // """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" 22 | } 23 | 24 | it("should properly extract the search query") { 25 | assert(urlObject.search === "?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") 26 | } 27 | 28 | it("should reconstituted the URL to match the original") { 29 | assert(URL.format(urlObject) === originalUrl) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.url 2 | 3 | import scala.scalajs.js 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class URLSearchParamsTest extends AnyFunSpec { 7 | describe("URLSearchParams") { 8 | it("should parse the string as a query string") { 9 | val params = new URLSearchParams("user=abc&query=xyz") 10 | assert(params.get("user") === "abc") 11 | assert(params.toString === "user=abc&query=xyz") 12 | } 13 | 14 | it("should parse the dictionary/object as a query string") { 15 | val params = new URLSearchParams( 16 | js.Dictionary( 17 | "user" -> "abc", 18 | "query" -> js.Array("first", "second") 19 | ) 20 | ) 21 | assert(params.getAll("query").toSeq === Seq("first,second")) 22 | } 23 | 24 | it("should iterates over each name-value pair in the query and invokes the given function") { 25 | val myURL = new URL("https://example.org/?a=b&c=d") 26 | val array = js.Array[String]() 27 | myURL.searchParams.forEach((value, name, searchParams) => { 28 | array.push(s"${name}=${value}") 29 | assert(myURL.searchParams === searchParams) 30 | }) 31 | assert(array(0) === "a=b") 32 | assert(array(1) === "c=d") 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/url/URLTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package url 3 | 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class URLTest extends AnyFunSpec { 7 | describe("URL") { 8 | it("Gets and sets the serialized query portion of the URL") { 9 | val myURL = new URL("https://example.org/abc?123") 10 | assert(myURL.search === "?123") 11 | 12 | myURL.search = "abc=xyz" 13 | assert(myURL.href === "https://example.org/abc?abc=xyz") 14 | } 15 | 16 | it("should support base URL string") { 17 | val url1 = new URL("/abc?123", "https://example.org") 18 | assert(url1.href === "https://example.org/abc?123") 19 | 20 | val url2 = new URL("/abc?123", new URL("https://example.org")) 21 | assert(url2.href === "https://example.org/abc?123") 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.util 2 | 3 | import scala.scalajs.js 4 | import org.scalatest.funspec.AnyFunSpec 5 | 6 | class UtilTest extends AnyFunSpec { 7 | it("have inspect object") { 8 | assert(Util.inspect !== null) 9 | assert(Util.inspect(js.Array(1, 2, 3)) === "[ 1, 2, 3 ]") 10 | val inspectOptions = InspectOptions(maxArrayLength = 1) 11 | assert(Util.inspect(js.Array(1, 2, 3), inspectOptions) === "[ 1, ... 2 more items ]") 12 | assert(Util.inspect.defaultOptions !== null) 13 | assert(Util.inspect.styles !== null) 14 | } 15 | 16 | it("have promisify") { 17 | assert(js.typeOf(Util.promisify(() => "")) === "function") 18 | assert(js.typeOf(Util.promisify.custom) === "symbol") 19 | } 20 | 21 | it("have TextEncoder/TextDecoder") { 22 | val encoder = new TextEncoder() 23 | val decoder = new TextDecoder() 24 | val encoded = encoder.encode("foobar") 25 | val decoded = decoder.decode(encoded) 26 | assert(decoded === "foobar") 27 | } 28 | 29 | it("have formatWithOptions added in v10.0.0") { 30 | assert( 31 | Util.formatWithOptions( 32 | InspectOptions(compact = true), 33 | "See object %O", 34 | new js.Object { 35 | val foo: Int = 42 36 | } 37 | ) === "See object { foo: 42 }" 38 | ) 39 | } 40 | 41 | it("have getSystemErrorName added in v9.7.0") { 42 | assert(Util.getSystemErrorName(-1) === "EPERM") 43 | } 44 | 45 | it("have types added in v10.0.0") { 46 | assert(Util.types.isDate(new js.Date)) 47 | } 48 | 49 | it("have inspect.custom added in v10.12.0") { 50 | assert(Util.inspect.custom !== null) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.vm 2 | 3 | import io.scalajs.nodejs.vm.VMTest.{ExpectedData, Sandbox} 4 | 5 | import scala.scalajs.js 6 | import org.scalatest.funspec.AnyFunSpec 7 | 8 | /** VM Tests 9 | */ 10 | class VMTest extends AnyFunSpec { 11 | describe("VM") { 12 | it("should compile and execute JavaScript code") { 13 | val sandbox = new Sandbox(animal = "cat", count = 2, name = "kitty") 14 | val expectedSet = Seq( 15 | ExpectedData(animal = "cat", count = 3, name = "kitty3"), 16 | ExpectedData(animal = "cat", count = 4, name = "kitty4"), 17 | ExpectedData(animal = "cat", count = 5, name = "kitty5"), 18 | ExpectedData(animal = "cat", count = 6, name = "kitty6"), 19 | ExpectedData(animal = "cat", count = 7, name = "kitty7"), 20 | ExpectedData(animal = "cat", count = 8, name = "kitty8"), 21 | ExpectedData(animal = "cat", count = 9, name = "kitty9"), 22 | ExpectedData(animal = "cat", count = 10, name = "kitty10"), 23 | ExpectedData(animal = "cat", count = 11, name = "kitty11"), 24 | ExpectedData(animal = "cat", count = 12, name = "kitty12") 25 | ) 26 | 27 | val script = new Script("""count += 1; name = "kitty" + count""") 28 | val context = VM.createContext(sandbox) 29 | expectedSet foreach { case ExpectedData(animal, count, name) => 30 | script.runInContext(context) 31 | assert(sandbox.animal === animal && sandbox.count === count && sandbox.name === name) 32 | } 33 | } 34 | 35 | it("should compile and execute JavaScript code in a custom context") { 36 | val sandbox = new Sandbox(animal = "cat", count = 2, name = "kitty") 37 | VM.runInNewContext("""count += 1; name = "kitty"""", sandbox) 38 | assert(sandbox.animal === "cat" && sandbox.count === 3 && sandbox.name === "kitty") 39 | } 40 | } 41 | } 42 | 43 | /** VM Test Companion 44 | */ 45 | object VMTest { 46 | 47 | /** Sandbox Object 48 | */ 49 | class Sandbox(var animal: String, var count: Int, var name: String) extends js.Object 50 | 51 | case class ExpectedData(animal: String, count: Int, name: String) 52 | } 53 | -------------------------------------------------------------------------------- /app/nodejs-v12/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.zlib 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue 6 | import org.scalatest.funspec.AnyFunSpec 7 | 8 | class ZlibTest extends AnyFunSpec { 9 | describe("Zlib") { 10 | it("should compress strings and buffers") { 11 | val original = Buffer.from("This is a compression example") 12 | 13 | for { 14 | compressed <- Zlib.deflateFuture(original) 15 | uncompressed <- Zlib.unzipFuture(compressed, CompressionOptions(finishFlush = Zlib.Z_SYNC_FLUSH)) 16 | } { 17 | assert(original.compare(uncompressed) === 0) 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/AbortController.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import com.thoughtworks.enableMembersIf 4 | import io.scalajs.nodejs.events.EventTarget 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSGlobal 8 | 9 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 10 | @js.native 11 | @JSGlobal("AbortController") 12 | class AbortController extends js.Object { 13 | def abort(): Unit = js.native 14 | def signal: AbortSignal = js.native 15 | } 16 | 17 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 18 | @js.native 19 | @JSGlobal("AbortSignal") 20 | class AbortSignal private[this] () extends EventTarget { 21 | def aborted: Boolean = js.native 22 | } 23 | 24 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 25 | @js.native 26 | @JSGlobal("AbortSignal") 27 | object AbortSignal extends js.Object { 28 | def abort(): AbortSignal = js.native 29 | } 30 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/HasFileDescriptor.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | trait HasFileDescriptor extends js.Object { 6 | def fd: FileDescriptor 7 | } 8 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/HasHandle.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | trait HasHandle extends js.Object { 6 | def _handle: js.Any 7 | } 8 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/Module.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | /** In each module, the module free variable is a reference to the object representing the current module. For 6 | * convenience, module.exports is also accessible via the exports module-global. module isn't actually a global but 7 | * rather local to each module. 8 | * @see 9 | * [[https://nodejs.org/api/modules.html#modules_the_module_object]] 10 | */ 11 | @js.native 12 | trait Module extends js.Object { 13 | 14 | /** The module objects required by this one. 15 | * @example 16 | * module.children 17 | */ 18 | var children: js.Array[Module] = js.native 19 | 20 | /** The module.exports object is created by the Module system. Sometimes this is not acceptable; many want their 21 | * module to be an instance of some class. To do this, assign the desired export object to module.exports. Note that 22 | * assigning the desired object to exports will simply rebind the local exports variable, which is probably not what 23 | * you want to do. 24 | * @example 25 | * module.exports 26 | */ 27 | var exports: js.Object = js.native 28 | 29 | /** The fully resolved filename to the module. 30 | * @example 31 | * module.filename 32 | */ 33 | var filename: String = js.native 34 | 35 | /** The identifier for the module. Typically this is the fully resolved filename. 36 | * @example 37 | * module.id 38 | */ 39 | var id: String = js.native 40 | 41 | /** Whether or not the module is done loading, or is in the process of loading. 42 | * @example 43 | * module.loaded 44 | */ 45 | var loaded: Boolean = js.native 46 | 47 | /** The module that first required this one. 48 | * @example 49 | * module.parent 50 | */ 51 | var parent: js.Any = js.native 52 | 53 | var paths: js.Array[String] = js.native 54 | 55 | /** The module.require method provides a way to load a module as if require() was called from the original module. 56 | *

Note that in order to do this, you must get a reference to the module object. Since require() returns 57 | * the module.exports, and the module is typically only available within a specific module's code, it must be 58 | * explicitly exported in order to be used. 59 | */ 60 | def require[T <: js.Any](id: String): T = js.native 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/Require.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSGlobal 5 | 6 | @js.native 7 | sealed trait Require extends js.Object { 8 | def apply(id: String): js.Any = js.native 9 | 10 | val cache: js.Dictionary[js.Any] = js.native 11 | val main: js.UndefOr[Module] = js.native 12 | val resolve: RequireResolver = js.native 13 | } 14 | 15 | @js.native 16 | @JSGlobal("require") 17 | object Require extends Require 18 | 19 | @js.native 20 | trait RequireResolver extends js.Object { 21 | def apply(request: String, options: ResolveOptions): js.Any = js.native 22 | def apply(request: String): js.Any = js.native 23 | 24 | def paths(requiest: String): js.Array[String] = js.native 25 | } 26 | 27 | trait ResolveOptions extends js.Object { 28 | var paths: js.UndefOr[js.Array[String]] = js.undefined 29 | } 30 | object ResolveOptions { 31 | def apply( 32 | paths: js.UndefOr[js.Array[String]] = js.undefined 33 | ): ResolveOptions = { 34 | val _obj$ = js.Dynamic.literal( 35 | ) 36 | paths.foreach(_v => _obj$.updateDynamic("paths")(_v.asInstanceOf[js.Any])) 37 | _obj$.asInstanceOf[ResolveOptions] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/StringDecoder.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import io.scalajs.nodejs.events.IEventEmitter 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | import scala.scalajs.js.typedarray.{DataView, TypedArray} 8 | 9 | /** To use this module, do require('string_decoder'). StringDecoder decodes a buffer to a string. It is a simple 10 | * interface to Buffer.toString() but provides additional support for utf8. 11 | */ 12 | @js.native 13 | @JSImport("string_decoder", "StringDecoder") 14 | class StringDecoder() extends IEventEmitter { 15 | def this(encoding: String) = this() 16 | 17 | /** Returns any trailing bytes that were left in the buffer. 18 | * @example 19 | * decoder.end() 20 | */ 21 | def end(buffer: TypedArray[_, _]): String = js.native 22 | def end(buffer: DataView): String = js.native 23 | def end(): String = js.native 24 | 25 | /** Returns a decoded string. 26 | * @example 27 | * decoder.write(buffer) 28 | */ 29 | def write(buffer: TypedArray[_, _]): String = js.native 30 | def write(buffer: DataView): String = js.native 31 | } 32 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/buffer/Blob.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.buffer 2 | 3 | import com.thoughtworks.enableMembersIf 4 | import io.scalajs.nodejs.webstream 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.{JSImport, JSName} 8 | import scala.scalajs.js.typedarray.ArrayBuffer 9 | 10 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 11 | @js.native 12 | @JSImport("buffer", "Blob") 13 | class Blob() extends js.Object { 14 | 15 | def this(source: BlobSources, options: BlobOptions) = this() 16 | def this(source: BlobSources) = this() 17 | 18 | def arrayBuffer(): js.Promise[ArrayBuffer] = js.native 19 | 20 | def size: Double = js.native 21 | 22 | def slice(start: Double, end: Double, `type`: String): Blob = js.native 23 | def slice(start: Double, end: Double): Blob = js.native 24 | def slice(start: Double): Blob = js.native 25 | 26 | def text(): js.Promise[String] = js.native 27 | 28 | def `type`: String = js.native 29 | 30 | /** Alias for [[`type`]] 31 | */ 32 | @JSName("type") 33 | def contentType: String = js.native 34 | 35 | def stream(): webstream.ReadableStream = js.native 36 | } 37 | 38 | trait BlobOptions extends js.Object { 39 | var encoding: js.UndefOr[String] = js.undefined 40 | var `type`: js.UndefOr[String] = js.undefined 41 | } 42 | object BlobOptions { 43 | def apply( 44 | encoding: js.UndefOr[String] = js.undefined, 45 | `type`: js.UndefOr[String] = js.undefined 46 | ): BlobOptions = { 47 | val _obj$ = js.Dynamic.literal( 48 | ) 49 | encoding.foreach(_v => _obj$.updateDynamic("encoding")(_v.asInstanceOf[js.Any])) 50 | `type`.foreach(_v => _obj$.updateDynamic("type")(_v.asInstanceOf[js.Any])) 51 | _obj$.asInstanceOf[BlobOptions] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/child_process/ForkOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package child_process 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.| 6 | 7 | trait ForkOptions extends js.Object { 8 | 9 | /** Current working directory of the child process */ 10 | var cwd: js.UndefOr[String] = js.undefined 11 | 12 | /** Prepare child to run independently of its parent process Specific behavior depends on the platform (see 13 | * options.detached). 14 | */ 15 | var detached: js.UndefOr[Boolean] = js.undefined 16 | 17 | /** Environment key-value pairs */ 18 | var env: js.UndefOr[js.Object] = js.undefined 19 | 20 | /** Executable used to create the child process */ 21 | var execPath: js.UndefOr[String] = js.undefined 22 | 23 | /** List of string arguments passed to the executable (Default: process.execArgv) */ 24 | var execArgv: js.UndefOr[Array[String]] = js.undefined 25 | 26 | /** From Node.js v13.2.0, v12.16.0. Specify the kind of serialization used for sending messages between processes. 27 | * Possible values are 'json' and 'advanced'. See Advanced Serialization for more details. Default: 'json'. 28 | */ 29 | var serialization: js.UndefOr[String] = js.undefined 30 | 31 | /** If true, stdin, stdout, and stderr of the child will be piped to the parent, otherwise they will be inherited from 32 | * the parent, see the 'pipe' and 'inherit' options for child_process.spawn()'s stdio for more details (Default: 33 | * false) 34 | */ 35 | var silent: js.UndefOr[Boolean] = js.undefined 36 | 37 | /** Supports the array version of child_process.spawn()'s stdio option. When this option is provided, it overrides 38 | * silent. The array must contain exactly one item with value 'ipc' or an error will be thrown. For instance [0, 1, 39 | * 2, 'ipc']. 40 | */ 41 | var stdio: js.UndefOr[String | Array[String]] = js.undefined 42 | 43 | /** Sets the user identity of the process. (See setuid(2).) */ 44 | var uid: js.UndefOr[UID] = js.undefined 45 | 46 | /** Sets the group identity of the process. (See setgid(2).) */ 47 | var gid: js.UndefOr[GID] = js.undefined 48 | } 49 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/child_process/SendOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.child_process 2 | 3 | import scala.scalajs.js 4 | 5 | trait SendOptions extends js.Object { 6 | var keepOpen: js.UndefOr[Boolean] = js.undefined 7 | } 8 | object SendOptions { 9 | def apply( 10 | keepOpen: js.UndefOr[Boolean] = js.undefined 11 | ): SendOptions = { 12 | val _obj$ = js.Dynamic.literal( 13 | ) 14 | keepOpen.foreach(_v => _obj$.updateDynamic("keepOpen")(_v.asInstanceOf[js.Any])) 15 | _obj$.asInstanceOf[SendOptions] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/child_process/SpawnOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.child_process 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.| 5 | 6 | trait SpawnOptions extends js.Object { 7 | 8 | /** Current working directory of the child process */ 9 | var cwd: js.UndefOr[String] = js.undefined 10 | 11 | /** Environment key-value pairs */ 12 | var env: js.UndefOr[js.Object] = js.undefined 13 | 14 | /** Explicitly set the value of argv[0] sent to the child process. This will be set to command if not specified. 15 | */ 16 | var argv0: js.UndefOr[String] = js.undefined 17 | 18 | /** Child's stdio configuration. (See options.stdio) */ 19 | var stdio: js.UndefOr[StdIo] = js.undefined 20 | 21 | /** Prepare child to run independently of its parent process. Specific behavior depends on the platform, see 22 | * options.detached) 23 | */ 24 | var detached: js.UndefOr[Boolean] = js.undefined 25 | 26 | /** Sets the user identity of the process. (See setuid(2).) */ 27 | var uid: js.UndefOr[Int] = js.undefined 28 | 29 | /** Sets the group identity of the process. (See setgid(2).) */ 30 | var gid: js.UndefOr[Int] = js.undefined 31 | 32 | /** If true, runs command inside of a shell. Uses '/bin/sh' on UNIX, and 'cmd.exe' on Windows. A different shell can 33 | * be specified as a string. The shell should understand the -c switch on UNIX, or /d /s /c on Windows. Defaults to 34 | * false (no shell). 35 | */ 36 | var shell: js.UndefOr[Boolean | String] = js.undefined 37 | 38 | /** No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to true automatically when 39 | * shell is specified and is CMD. Default: false. 40 | */ 41 | var windowsVerbatimArguments: js.UndefOr[Boolean] = js.undefined 42 | 43 | /** Hide the subprocess console window that would normally be created on Windows systems. Default: `false`. 44 | */ 45 | var windowsHide: js.UndefOr[Boolean] = js.undefined 46 | } 47 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/child_process/SpawnSyncResult.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.child_process 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.| 5 | 6 | trait SpawnSyncResult extends js.Object { 7 | var pid: Int 8 | var output: js.Array[Output] 9 | var stdout: Output 10 | var stderr: Output 11 | var status: Int | Null 12 | var signal: String | Null 13 | var error: js.UndefOr[js.Error] = js.undefined 14 | } 15 | 16 | object SpawnSyncResult { 17 | def apply( 18 | pid: Int, 19 | output: js.Array[Output], 20 | stdout: Output, 21 | stderr: Output, 22 | status: Int | Null = null, 23 | signal: String | Null = null, 24 | error: js.UndefOr[js.Error] = js.undefined 25 | ): SpawnSyncResult = { 26 | val _obj$ = js.Dynamic.literal( 27 | "pid" -> pid.asInstanceOf[js.Any], 28 | "output" -> output.asInstanceOf[js.Any], 29 | "stdout" -> stdout.asInstanceOf[js.Any], 30 | "stderr" -> stderr.asInstanceOf[js.Any], 31 | "status" -> status.asInstanceOf[js.Any], 32 | "signal" -> signal.asInstanceOf[js.Any] 33 | ) 34 | error.foreach(_v => _obj$.updateDynamic("error")(_v.asInstanceOf[js.Any])) 35 | _obj$.asInstanceOf[SpawnSyncResult] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/child_process/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import io.scalajs.nodejs 4 | import io.scalajs.util.PromiseHelper._ 5 | 6 | import scala.concurrent.Future 7 | import scala.scalajs.js 8 | import scala.scalajs.js.typedarray.{DataView, TypedArray} 9 | import scala.scalajs.js.| 10 | 11 | package object child_process { 12 | type Output = nodejs.buffer.Buffer | String 13 | type Input = String | nodejs.buffer.Buffer | TypedArray[_, _] | DataView 14 | type StdIo = String | js.Array[String] | js.Array[io.scalajs.nodejs.FileDescriptor] | js.Array[ 15 | String | io.scalajs.nodejs.FileDescriptor 16 | ] 17 | type KillSignal = Int | String 18 | type ExecCallback = js.Function3[nodejs.Error, Output, Output, Any] 19 | 20 | implicit final class ChildProcessObjectExtensions(private val cp: ChildProcess.type) extends AnyVal { 21 | @inline 22 | def execFuture(command: String, options: ExecOptions): Future[(Output, Output)] = { 23 | promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, options, _)) 24 | } 25 | 26 | @inline 27 | def execFuture(command: String): Future[(Output, Output)] = { 28 | promiseWithError2[nodejs.Error, Output, Output](cp.exec(command, _)) 29 | } 30 | 31 | @inline 32 | def execFileFuture(file: String, args: js.Array[String], options: ExecOptions): Future[(Output, Output)] = { 33 | promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args, options, _)) 34 | } 35 | 36 | @inline 37 | def execFileFuture(file: String, args: js.Array[String]): Future[(Output, Output)] = { 38 | promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, args, _)) 39 | } 40 | 41 | @inline 42 | def execFileFuture(file: String, options: ExecOptions): Future[(Output, Output)] = { 43 | promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, options, _)) 44 | } 45 | 46 | @inline 47 | def execFileFuture(file: String): Future[(Output, Output)] = { 48 | promiseWithError2[nodejs.Error, Output, Output](cp.execFile(file, _)) 49 | } 50 | } 51 | 52 | implicit final class ChildProcessExtensions(private val cp: ChildProcess) extends AnyVal { 53 | @inline 54 | def onClose(listener: (Int, String) => Any): ChildProcess = cp.on("close", listener) 55 | 56 | @inline 57 | def onDisconnect(listener: () => Any): ChildProcess = cp.on("disconnect", listener) 58 | 59 | @inline 60 | def onError(listener: (js.Error) => Any): ChildProcess = cp.on("error", listener) 61 | 62 | @inline 63 | def onMessage(listener: (js.Any, js.UndefOr[net.Socket | net.Server]) => Any): ChildProcess = 64 | cp.on("message", listener) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/cluster/Address.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.cluster 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.| 5 | 6 | @js.native 7 | trait Address extends js.Object { 8 | def address: String = js.native 9 | 10 | def port: Int = js.native 11 | 12 | /** The addressType is one of: 4 (TCPv4) 6 (TCPv6) -1 (unix domain socket) "udp4" or "udp6" (UDP v4 or v6) 13 | */ 14 | def addressType: String | Int = js.native 15 | } 16 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/cluster/ClusterSettings.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.cluster 2 | 3 | import io.scalajs.nodejs.{GID, UID} 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.| 7 | 8 | /** Cluster Settings 9 | */ 10 | trait ClusterSettings extends js.Object { 11 | 12 | /** list of string arguments passed to the Node.js executable. (Default=process.execArgv) */ 13 | var execArgv: js.Array[String] 14 | 15 | /** file path to worker file. (Default=process.argv[1]) */ 16 | var exec: String 17 | 18 | /** string arguments passed to worker. (Default=process.argv.slice(2)) */ 19 | var args: js.Array[String] 20 | 21 | /** whether or not to send output to parent's stdio. (Default=false) */ 22 | var silent: Boolean 23 | 24 | /** Specify the kind of serialization used for sending messages between processes. Possible values are 'json' and 25 | * 'advanced'. See Advanced Serialization for more details. Default: 'json'. 26 | * 27 | * From Node.js v13.2.0, v12.16.0. 28 | */ 29 | var serialization: js.UndefOr[String] 30 | 31 | /** Sets the user identity of the process. (See setuid(2).) */ 32 | var uid: UID 33 | 34 | /** Sets the group identity of the process. (See setgid(2).) */ 35 | var gid: GID 36 | 37 | var stdio: js.Array[js.Any] 38 | 39 | var inspectPort: Int | js.Function 40 | 41 | var cwd: String 42 | 43 | var windowsHide: Boolean 44 | } 45 | 46 | object ClusterSettings { 47 | def apply( 48 | execArgv: js.Array[String], 49 | exec: String, 50 | args: js.Array[String], 51 | silent: Boolean, 52 | uid: UID, 53 | gid: GID, 54 | stdio: js.Array[js.Any], 55 | inspectPort: Int | js.Function, 56 | cwd: String, 57 | windowsHide: Boolean, 58 | serialization: js.UndefOr[String] = js.undefined 59 | ): ClusterSettings = { 60 | val _obj$ = js.Dynamic.literal( 61 | "execArgv" -> execArgv.asInstanceOf[js.Any], 62 | "exec" -> exec.asInstanceOf[js.Any], 63 | "args" -> args.asInstanceOf[js.Any], 64 | "silent" -> silent.asInstanceOf[js.Any], 65 | "serialization" -> serialization.asInstanceOf[js.Any], 66 | "uid" -> uid.asInstanceOf[js.Any], 67 | "gid" -> gid.asInstanceOf[js.Any], 68 | "stdio" -> stdio.asInstanceOf[js.Any], 69 | "inspectPort" -> inspectPort.asInstanceOf[js.Any], 70 | "cwd" -> cwd.asInstanceOf[js.Any], 71 | "windowsHide" -> windowsHide.asInstanceOf[js.Any] 72 | ) 73 | _obj$.asInstanceOf[ClusterSettings] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/console_module/ConsoleDirOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.console_module 2 | 3 | import scala.scalajs.js 4 | 5 | trait ConsoleDirOptions extends js.Object { 6 | 7 | /** if true then the object's non-enumerable and symbol properties will be shown too. Defaults to `false`. 8 | */ 9 | var showHidden: js.UndefOr[Boolean] = js.undefined 10 | 11 | /** tells util.inspect() how many times to recurse while formatting the object. This is useful for inspecting large 12 | * complicated objects. Defaults to `2`. To make it recurse indefinitely, pass null. 13 | */ 14 | var depth: js.UndefOr[Int] = js.undefined 15 | 16 | /** if true, then the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable;see 17 | * customizing util.inspect() colors. 18 | */ 19 | var colors: js.UndefOr[Boolean] = js.undefined 20 | } 21 | 22 | object ConsoleDirOptions { 23 | def apply( 24 | showHidden: js.UndefOr[Boolean] = js.undefined, 25 | depth: js.UndefOr[Int] = js.undefined, 26 | colors: js.UndefOr[Boolean] = js.undefined 27 | ): ConsoleDirOptions = { 28 | val _obj$ = js.Dynamic.literal( 29 | ) 30 | showHidden.foreach(_v => _obj$.updateDynamic("showHidden")(_v.asInstanceOf[js.Any])) 31 | depth.foreach(_v => _obj$.updateDynamic("depth")(_v.asInstanceOf[js.Any])) 32 | colors.foreach(_v => _obj$.updateDynamic("colors")(_v.asInstanceOf[js.Any])) 33 | _obj$.asInstanceOf[ConsoleDirOptions] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/console_module/ConsoleOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.console_module 2 | 3 | import io.scalajs.nodejs.stream.IWritable 4 | import io.scalajs.nodejs.util.InspectOptions 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.| 8 | 9 | trait ConsoleOptions extends js.Object { 10 | var stdout: IWritable 11 | var stderr: js.UndefOr[IWritable] = js.undefined 12 | 13 | /** Ignore errors when writing to the underlying streams. Defaults to `true`. 14 | */ 15 | var ignoreErrors: js.UndefOr[Boolean] = js.undefined 16 | 17 | /** Set color support for this `Console` instance. Setting to `true` enables coloring while inspecting values, setting 18 | * to `'auto'` will make color support depend on the value of the `isTTY` property and the value returned by 19 | * `getColorDepth()` on the respective stream. This option can not be used, if `inspectOptions.colors` is set as 20 | * well. Defaults to `'auto'`. 21 | */ 22 | var colorMode: js.UndefOr[Boolean | String] = js.undefined 23 | 24 | /** Specifies options that are passed along to [[io.scalajs.nodejs.util.Util.inspect()]]. Node.js v11.7.0. 25 | */ 26 | var inspectOptions: js.UndefOr[InspectOptions] = js.undefined 27 | 28 | /** Set group indentation. Default: 2. Node.js v14.2.0. 29 | */ 30 | var groupIndentation: js.UndefOr[Int] = js.undefined 31 | } 32 | 33 | object ConsoleOptions { 34 | def apply( 35 | stdout: IWritable, 36 | stderr: js.UndefOr[IWritable] = js.undefined, 37 | ignoreErrors: js.UndefOr[Boolean] = js.undefined, 38 | colorMode: js.UndefOr[Boolean | String] = js.undefined, 39 | inspectOptions: js.UndefOr[InspectOptions] = js.undefined, 40 | groupIndentation: js.UndefOr[Int] = js.undefined 41 | ): ConsoleOptions = { 42 | val _obj$ = js.Dynamic.literal( 43 | "stdout" -> stdout.asInstanceOf[js.Any] 44 | ) 45 | stderr.foreach(_v => _obj$.updateDynamic("stderr")(_v.asInstanceOf[js.Any])) 46 | ignoreErrors.foreach(_v => _obj$.updateDynamic("ignoreErrors")(_v.asInstanceOf[js.Any])) 47 | colorMode.foreach(_v => _obj$.updateDynamic("colorMode")(_v.asInstanceOf[js.Any])) 48 | inspectOptions.foreach(_v => _obj$.updateDynamic("inspectOptions")(_v.asInstanceOf[js.Any])) 49 | groupIndentation.foreach(_v => _obj$.updateDynamic("groupIndentation")(_v.asInstanceOf[js.Any])) 50 | _obj$.asInstanceOf[ConsoleOptions] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | @JSImport("crypto", "Certificate") 10 | object Certificate extends js.Object { 11 | def exportChallenge(spkac: String): Buffer = js.native 12 | def exportChallenge(spkac: BufferLike): Buffer = js.native 13 | 14 | def exportPublicKey(spkac: String, encoding: String): Buffer = js.native 15 | def exportPublicKey(spkac: String): Buffer = js.native 16 | def exportPublicKey(spkac: BufferLike): Buffer = js.native 17 | 18 | def verifySpkac(spkac: BufferLike): Boolean = js.native 19 | } 20 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/DiffieHellman.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | 7 | @js.native 8 | trait DiffieHellman extends js.Object { 9 | def computeSecret(otherPublicKey: String, inputEncoding: String, outputEncoding: String): String = js.native 10 | def computeSecret(otherPublicKey: String, inputEncoding: String): Buffer = js.native 11 | def computeSecret(otherPublicKey: BufferLike, inputEncoding: Null, outputEncoding: String): String = js.native 12 | def computeSecret(otherPublicKey: BufferLike): Buffer = js.native 13 | 14 | def generateKeys(): Buffer = js.native 15 | def generateKeys(encoding: String): String = js.native 16 | 17 | def getGenerator(): Buffer = js.native 18 | def getGenerator(encoding: String): String = js.native 19 | 20 | def getPrime(): Buffer = js.native 21 | def getPrime(encoding: String): String = js.native 22 | 23 | def getPrivateKey(): Buffer = js.native 24 | def getPrivateKey(encoding: String): String = js.native 25 | 26 | def getPublicKey(): Buffer = js.native 27 | def getPublicKey(encoding: String): String = js.native 28 | 29 | def setPrivateKey(privateKey: String, encoding: String): DiffieHellman = js.native 30 | def setPrivateKey(privateKey: BufferLike): DiffieHellman = js.native 31 | 32 | def setPublicKey(privateKey: String, encoding: String): DiffieHellman = js.native 33 | def setPublicKey(privateKey: BufferLike): DiffieHellman = js.native 34 | 35 | val verifyError: Int = js.native 36 | } 37 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/DiffieHellmanGroup.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | 7 | // NOT inherit DiffieHellman 8 | @js.native 9 | trait DiffieHellmanGroup extends js.Object { 10 | def computeSecret(otherPublicKey: String, inputEncoding: String, outputEncoding: String): String = js.native 11 | def computeSecret(otherPublicKey: String, inputEncoding: String): Buffer = js.native 12 | def computeSecret(otherPublicKey: BufferLike, inputEncoding: Null, outputEncoding: String): String = js.native 13 | def computeSecret(otherPublicKey: BufferLike): Buffer = js.native 14 | 15 | def generateKeys(): Buffer = js.native 16 | def generateKeys(encoding: String): String = js.native 17 | 18 | def getGenerator(): Buffer = js.native 19 | def getGenerator(encoding: String): String = js.native 20 | 21 | def getPrime(): Buffer = js.native 22 | def getPrime(encoding: String): String = js.native 23 | 24 | def getPrivateKey(): Buffer = js.native 25 | def getPrivateKey(encoding: String): String = js.native 26 | 27 | def getPublicKey(): Buffer = js.native 28 | def getPublicKey(encoding: String): String = js.native 29 | 30 | def setPrivateKey(privateKey: String, encoding: String): DiffieHellmanGroup = js.native 31 | def setPrivateKey(privateKey: BufferLike): DiffieHellmanGroup = js.native 32 | 33 | def setPublicKey(privateKey: String, encoding: String): DiffieHellmanGroup = js.native 34 | def setPublicKey(privateKey: BufferLike): DiffieHellmanGroup = js.native 35 | 36 | val verifyError: Int = js.native 37 | } 38 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/DiffieHellmanOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import scala.scalajs.js 4 | 5 | trait DiffieHellmanOptions extends js.Object { 6 | var privateKey: KeyObject 7 | var publicKey: KeyObject 8 | } 9 | object DiffieHellmanOptions { 10 | def apply( 11 | privateKey: KeyObject, 12 | publicKey: KeyObject 13 | ): DiffieHellmanOptions = { 14 | val _obj$ = js.Dynamic.literal( 15 | "privateKey" -> privateKey.asInstanceOf[js.Any], 16 | "publicKey" -> publicKey.asInstanceOf[js.Any] 17 | ) 18 | _obj$.asInstanceOf[DiffieHellmanOptions] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/ECDH.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | // NOT inherit DiffieHellman 9 | @js.native 10 | trait ECDH extends js.Object { 11 | def computeSecret(otherPublicKey: String, inputEncoding: String, outputEncoding: String): String = js.native 12 | def computeSecret(otherPublicKey: String, inputEncoding: String): Buffer = js.native 13 | def computeSecret(otherPublicKey: BufferLike, inputEncoding: Null, outputEncoding: String): String = js.native 14 | def computeSecret(otherPublicKey: BufferLike): Buffer = js.native 15 | 16 | def generateKeys(): Buffer = js.native 17 | def generateKeys(encoding: Null, format: String): Buffer = js.native 18 | def generateKeys(encoding: String, format: String): String = js.native 19 | 20 | def getPrivateKey(): Buffer = js.native 21 | def getPrivateKey(encoding: String): String = js.native 22 | 23 | def getPublicKey(): Buffer = js.native 24 | def getPublicKey(encoding: Null, format: String): Buffer = js.native 25 | def getPublicKey(encoding: String): String = js.native 26 | def getPublicKey(encoding: String, format: String): String = js.native 27 | 28 | def setPrivateKey(privateKey: String, encoding: String): ECDH = js.native 29 | def setPrivateKey(privateKey: BufferLike): ECDH = js.native 30 | } 31 | 32 | @js.native 33 | @JSImport("crypto", "ECDH") 34 | object ECDH extends js.Object { 35 | def convertKey(key: String, curve: String, inputEncoding: String, outputEncoding: String, format: String): String = 36 | js.native 37 | def convertKey(key: BufferLike, curve: String, inputEncoding: Null, outputEncoding: String, format: String): String = 38 | js.native 39 | def convertKey(key: String, curve: String, inputEncoding: String, outputEncoding: String): String = js.native 40 | def convertKey(key: BufferLike, curve: String, inputEncoding: Null, outputEncoding: String): String = js.native 41 | def convertKey(key: String, curve: String, inputEncoding: String): Buffer = js.native 42 | def convertKey(key: BufferLike, curve: String, inputEncoding: Null): Buffer = js.native 43 | def convertKey(key: BufferLike, curve: String): Buffer = js.native 44 | def convertKey(key: BufferLike): Buffer = js.native 45 | } 46 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | import io.scalajs.nodejs.stream.Writable 5 | 6 | import scala.scalajs.js 7 | 8 | /** The Sign Class is a utility for generating signatures. It can be used in one of two ways: 9 | * 10 | *

  • As a writable stream, where data to be signed is written and the sign.sign() method is used to generate and 11 | * return the signature, or
  • Using the sign.update() and sign.sign() methods to produce the signature.
  • 12 | * 13 | * The crypto.createSign() method is used to create Sign instances. Sign objects are not to be created directly using 14 | * the new keyword. 15 | */ 16 | @js.native 17 | sealed trait Sign extends Writable { 18 | def sign(privateKey: String): Buffer = js.native 19 | def sign(privateKey: Buffer): Buffer = js.native 20 | def sign(privateKey: String, outputEncoding: String): String = js.native 21 | def sign(privateKey: Buffer, outputEncoding: String): String = js.native 22 | def sign(privateKey: KeyObject): Buffer = js.native 23 | def sign(privateKey: KeyObject, outputEncoding: String): String = js.native 24 | 25 | def update(data: String, inputEncoding: String): Unit = js.native 26 | def update(data: String): Unit = js.native 27 | def update(data: BufferLike): Unit = js.native 28 | } 29 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/crypto/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import io.scalajs.nodejs.{Error => NodeError} 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.typedarray.{DataView, TypedArray} 7 | import scala.scalajs.js.| 8 | 9 | package object crypto { 10 | type BufferLike = TypedArray[_, _] | DataView 11 | type Callback1[T] = js.Function2[NodeError, T, Any] 12 | type Callback2[T1, T2] = js.Function3[NodeError, T1, T2, Any] 13 | 14 | implicit final class CryptoModuleEnrichment(private val crypto: Crypto.type) extends AnyVal { 15 | @inline def Certificate: io.scalajs.nodejs.crypto.Certificate.type = io.scalajs.nodejs.crypto.Certificate 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/Dgram.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.dgram 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSImport 5 | 6 | @js.native 7 | trait Dgram extends js.Object { 8 | def createSocket(options: SocketOptions, callback: js.Function): Socket = js.native 9 | def createSocket(options: SocketOptions): Socket = js.native 10 | def createSocket(`type`: String, callback: js.Function): Socket = js.native 11 | def createSocket(`type`: String): Socket = js.native 12 | } 13 | 14 | trait SocketOptions extends js.Object { 15 | var `type`: String 16 | 17 | var reuseAddr: js.UndefOr[Boolean] = js.undefined 18 | var ipv6Only: js.UndefOr[Boolean] = js.undefined 19 | var recvBufferSize: js.UndefOr[Int] = js.undefined 20 | var sendBufferSize: js.UndefOr[Int] = js.undefined 21 | var lookup: js.UndefOr[js.Function1[String, Any]] = js.undefined 22 | } 23 | object SocketOptions { 24 | def apply( 25 | `type`: String, 26 | reuseAddr: js.UndefOr[Boolean] = js.undefined, 27 | ipv6Only: js.UndefOr[Boolean] = js.undefined, 28 | recvBufferSize: js.UndefOr[Int] = js.undefined, 29 | sendBufferSize: js.UndefOr[Int] = js.undefined, 30 | lookup: js.UndefOr[js.Function1[String, Any]] = js.undefined 31 | ): SocketOptions = { 32 | val _obj$ = js.Dynamic.literal( 33 | "type" -> `type`.asInstanceOf[js.Any] 34 | ) 35 | reuseAddr.foreach(_v => _obj$.updateDynamic("reuseAddr")(_v.asInstanceOf[js.Any])) 36 | ipv6Only.foreach(_v => _obj$.updateDynamic("ipv6Only")(_v.asInstanceOf[js.Any])) 37 | recvBufferSize.foreach(_v => _obj$.updateDynamic("recvBufferSize")(_v.asInstanceOf[js.Any])) 38 | sendBufferSize.foreach(_v => _obj$.updateDynamic("sendBufferSize")(_v.asInstanceOf[js.Any])) 39 | lookup.foreach(_v => _obj$.updateDynamic("lookup")(_v.asInstanceOf[js.Any])) 40 | _obj$.asInstanceOf[SocketOptions] 41 | } 42 | } 43 | 44 | @js.native 45 | @JSImport("dgram", JSImport.Namespace) 46 | object Dgram extends Dgram 47 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dgram/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.typedarray.Uint8Array 7 | import scala.scalajs.js.| 8 | 9 | package object dgram { 10 | type StringMessage = String | js.Array[String] 11 | type Message = BufferMessage | StringMessage 12 | type BufferMessage = Uint8Array | js.Array[Uint8Array] 13 | 14 | implicit final class SocketExtensions[T <: Socket](private val instance: T) extends AnyVal { 15 | @inline def onConnect(handler: () => Any): T = instance.on("connect", handler) 16 | 17 | @inline def onClose(handler: () => Any): T = instance.on("close", handler) 18 | @inline def onError(handler: (Error) => Any): T = instance.on("error", handler) 19 | @inline def onListening(handler: () => Any): T = instance.on("listening", handler) 20 | @inline def onMessage(handler: (Buffer, RemoteAddressInfo) => Any): T = instance.on("message", handler) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dns/DnsOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.dns 2 | 3 | import scala.scalajs.js 4 | 5 | trait DnsOptions extends js.Object { 6 | var family: js.UndefOr[Int] = js.undefined 7 | var hints: js.UndefOr[Int] = js.undefined 8 | var all: js.UndefOr[Boolean] = js.undefined 9 | var verbatim: js.UndefOr[Boolean] = js.undefined 10 | } 11 | object DnsOptions { 12 | def apply( 13 | family: js.UndefOr[Int] = js.undefined, 14 | hints: js.UndefOr[Int] = js.undefined, 15 | all: js.UndefOr[Boolean] = js.undefined, 16 | verbatim: js.UndefOr[Boolean] = js.undefined 17 | ): DnsOptions = { 18 | val _obj$ = js.Dynamic.literal( 19 | ) 20 | family.foreach(_v => _obj$.updateDynamic("family")(_v.asInstanceOf[js.Any])) 21 | hints.foreach(_v => _obj$.updateDynamic("hints")(_v.asInstanceOf[js.Any])) 22 | all.foreach(_v => _obj$.updateDynamic("all")(_v.asInstanceOf[js.Any])) 23 | verbatim.foreach(_v => _obj$.updateDynamic("verbatim")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[DnsOptions] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dns/PromisesResolver.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.dns 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | @JSImport("dns", "promises.Resolver") 10 | class PromisesResolver extends js.Object { 11 | def getServers(): js.Array[String] = js.native 12 | def setServers(servers: js.Array[String]): Unit = js.native 13 | 14 | def resolve(hostname: String, rrtype: RRType): js.Promise[ResolveResult] = js.native 15 | def resolve(hostname: String): js.Promise[js.Array[String]] = js.native 16 | def resolve4(hostname: String, options: TtlOptions): js.Promise[js.Array[String]] = js.native 17 | def resolve4(hostname: String): js.Promise[js.Array[String]] = js.native 18 | def resolve6(hostname: String, options: TtlOptions): js.Promise[js.Array[String]] = js.native 19 | def resolve6(hostname: String): js.Promise[js.Array[String]] = js.native 20 | def resolveAny(hostname: String): js.Promise[js.Array[ResolveObject]] = js.native 21 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 22 | def resolveCaa(hostname: String): js.Promise[js.Array[ResolveObject]] = js.native 23 | def resolveCname(hostname: String): js.Promise[js.Array[String]] = js.native 24 | def resolveMx(hostname: String): js.Promise[js.Array[MX]] = js.native 25 | def resolveNaptr(hostname: String): js.Promise[js.Array[NAPTR]] = js.native 26 | def resolveNs(hostname: String): js.Promise[js.Array[String]] = js.native 27 | def resolveSoa(hostname: String): js.Promise[js.Array[SOA]] = js.native 28 | def resolveSrv(hostname: String): js.Promise[js.Array[SRV]] = js.native 29 | def resolvePtr(hostname: String): js.Promise[js.Array[String]] = js.native 30 | def resolveTxt(hostname: String): js.Promise[js.Array[String]] = js.native 31 | def reverse(ipAddress: String): js.Promise[js.Array[String]] = js.native 32 | 33 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 34 | def setDefaultResultOrder(order: String): js.Promise[Unit] = js.native 35 | } 36 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dns/ResolveObject.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.dns 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | sealed trait ResolveObject extends js.Object {} 7 | 8 | @js.native 9 | trait AddressTtl extends ResolveObject { 10 | val address: String = js.native 11 | val ttl: Int = js.native 12 | } 13 | 14 | @js.native 15 | trait ValueOnly extends ResolveObject { 16 | val value: String = js.native 17 | } 18 | 19 | @js.native 20 | trait MX extends ResolveObject { 21 | val priority: Int = js.native 22 | val exchange: String = js.native 23 | } 24 | 25 | @js.native 26 | trait NAPTR extends ResolveObject { 27 | val flags: String = js.native 28 | val service: String = js.native 29 | val regexp: String = js.native 30 | val replacement: String = js.native 31 | val order: Int = js.native 32 | val preference: Int = js.native 33 | } 34 | 35 | @js.native 36 | trait SOA extends ResolveObject { 37 | val nsname: String = js.native 38 | val hostmaster: String = js.native 39 | val serial: Int = js.native 40 | val refresh: Int = js.native 41 | val retry: Int = js.native 42 | val expire: Int = js.native 43 | val minttl: Int = js.native 44 | } 45 | 46 | @js.native 47 | trait SRV extends ResolveObject { 48 | val name: String = js.native 49 | val priority: Int = js.native 50 | val port: Int = js.native 51 | val weight: Int = js.native 52 | } 53 | 54 | @js.native 55 | trait TXT extends ResolveObject { 56 | val `type`: String = js.native 57 | val entires: js.Array[js.Array[String]] = js.native 58 | } 59 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/dns/TtlOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.dns 2 | 3 | import scala.scalajs.js 4 | 5 | trait TtlOptions extends js.Object { 6 | var ttl: js.UndefOr[Boolean] = js.undefined 7 | } 8 | object TtlOptions { 9 | def apply( 10 | ttl: js.UndefOr[Boolean] = js.undefined 11 | ): TtlOptions = { 12 | val _obj$ = js.Dynamic.literal( 13 | ) 14 | ttl.foreach(_v => _obj$.updateDynamic("ttl")(_v.asInstanceOf[js.Any])) 15 | _obj$.asInstanceOf[TtlOptions] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/events/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.| 5 | 6 | package object events { 7 | 8 | implicit final class EventEmitterExtensions[T <: EventEmitter](private val instance: T) extends AnyVal { 9 | @inline def onNewListener(listener: (String | js.Symbol, js.Function) => Any): T = 10 | instance.on("newListener", listener) 11 | 12 | @inline def onRemoveListener(listener: (String | js.Symbol, js.Function) => Any): T = 13 | instance.on("removeListener", listener) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/FSWatcher.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package fs 3 | 4 | import com.thoughtworks.enableIf 5 | import io.scalajs.nodejs.events.IEventEmitter 6 | 7 | import scala.scalajs.js 8 | 9 | /** fs.FSWatcher - Objects returned from fs.watch() are of this type. 10 | */ 11 | @js.native 12 | trait FSWatcher extends IEventEmitter { 13 | 14 | /** Stop watching for changes on the given fs.FSWatcher. 15 | * @example 16 | * watcher.close() 17 | * @since 0.5.8 18 | */ 19 | def close(): Unit = js.native 20 | 21 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 22 | def ref(): FSWatcher = js.native 23 | 24 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 25 | def unref(): FSWatcher = js.native 26 | } 27 | 28 | /** A successful call to fs.watchFile() method will return a new fs.StatWatcher object. 29 | */ 30 | @js.native 31 | trait FSStatWatcher extends IEventEmitter { 32 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 33 | def ref(): FSStatWatcher = js.native 34 | 35 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 36 | def unref(): FSStatWatcher = js.native 37 | } 38 | 39 | trait FSWatcherOptions extends js.Object { 40 | 41 | /** Specifies the character encoding to be used for the filename passed to the listener (default: "utf8") */ 42 | var encoding: js.UndefOr[String] = js.undefined 43 | 44 | /** Indicates whether the process should continue to run as long as files are being watched (default: true) */ 45 | var persistent: js.UndefOr[Boolean] = js.undefined 46 | 47 | /** Indicates whether all subdirectories should be watched, or only the current directory. The applies when a 48 | * directory is specified, and only on supported platforms (See Caveats) (default: false) 49 | */ 50 | var recursive: js.UndefOr[Boolean] = js.undefined 51 | } 52 | 53 | object FSWatcherOptions { 54 | def apply( 55 | encoding: js.UndefOr[String] = js.undefined, 56 | persistent: js.UndefOr[Boolean] = js.undefined, 57 | recursive: js.UndefOr[Boolean] = js.undefined 58 | ): FSWatcherOptions = { 59 | val _obj$ = js.Dynamic.literal( 60 | ) 61 | encoding.foreach(_v => _obj$.updateDynamic("encoding")(_v.asInstanceOf[js.Any])) 62 | persistent.foreach(_v => _obj$.updateDynamic("persistent")(_v.asInstanceOf[js.Any])) 63 | recursive.foreach(_v => _obj$.updateDynamic("recursive")(_v.asInstanceOf[js.Any])) 64 | _obj$.asInstanceOf[FSWatcherOptions] 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/ReadStream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package fs 3 | 4 | import com.thoughtworks.enableIf 5 | import io.scalajs.nodejs.buffer.Buffer 6 | 7 | import scala.scalajs.js 8 | import scala.scalajs.js.annotation.JSImport 9 | import scala.scalajs.js.| 10 | 11 | /** fs.ReadStream - ReadStream is a Readable Stream. 12 | * @see 13 | * https://nodejs.org/api/stream.html#stream_class_stream_readable 14 | */ 15 | @js.native 16 | @JSImport("fs", "ReadStream") 17 | class ReadStream(path: Path) extends stream.Readable { 18 | // /////////////////////////////////////////////////////////////////////////////// 19 | // Properties 20 | // /////////////////////////////////////////////////////////////////////////////// 21 | 22 | /** The number of bytes read so far. 23 | */ 24 | def bytesRead: js.UndefOr[Double] = js.native 25 | 26 | /** The path to the file the stream is reading from as specified in the first argument to fs.createReadStream(). If 27 | * path is passed as a string, then readStream.path will be a string. If path is passed as a Buffer, then 28 | * readStream.path will be a Buffer. 29 | */ 30 | def path: Buffer | String = js.native 31 | 32 | // /////////////////////////////////////////////////////////////////////////////// 33 | // Methods 34 | // /////////////////////////////////////////////////////////////////////////////// 35 | 36 | /** Undocumented method 37 | * @see 38 | * https://github.com/nodejs/node-v0.x-archive/blob/cfcb1de130867197cbc9c6012b7e84e08e53d032/lib/fs.js#L1597-L1620 39 | */ 40 | def close(callback: js.Function1[Unit, Any]): Unit = js.native 41 | 42 | val pending: Boolean = js.native 43 | } 44 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/fs/WriteStream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package fs 3 | 4 | import io.scalajs.nodejs.buffer.Buffer 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | import scala.scalajs.js.| 9 | 10 | /** fs.WriteStream - WriteStream is a Writable Stream. 11 | * @see 12 | * https://nodejs.org/api/fs.html#fs_class_fs_writestream 13 | */ 14 | @js.native 15 | @JSImport("fs", "WriteStream") 16 | class WriteStream(path: Path) extends stream.Writable { 17 | // /////////////////////////////////////////////////////////////////////////////// 18 | // Properties 19 | // /////////////////////////////////////////////////////////////////////////////// 20 | 21 | /** The number of bytes written so far. Does not include data that is still queued for writing. 22 | */ 23 | def bytesWritten: Double = js.native 24 | 25 | /** The path to the file the stream is writing to as specified in the first argument to fs.createWriteStream(). If 26 | * path is passed as a string, then writeStream.path will be a string. If path is passed as a Buffer, then 27 | * writeStream.path will be a Buffer. 28 | */ 29 | def path: Buffer | String = js.native 30 | 31 | // /////////////////////////////////////////////////////////////////////////////// 32 | // Methods 33 | // /////////////////////////////////////////////////////////////////////////////// 34 | 35 | /** Undocumented method 36 | * @see 37 | * https://github.com/nodejs/node-v0.x-archive/blob/cfcb1de130867197cbc9c6012b7e84e08e53d032/lib/fs.js#L1597-L1620 38 | */ 39 | def close(callback: js.Function1[Unit, Any]): Unit = js.native 40 | } 41 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/AgentOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import scala.scalajs.js 4 | 5 | trait AgentOptions extends js.Object { 6 | var keepAlive: js.UndefOr[Boolean] = js.undefined 7 | var keepAliveMsecs: js.UndefOr[Int] = js.undefined 8 | var maxSockets: js.UndefOr[Double] = js.undefined 9 | var maxFreeSockets: js.UndefOr[Int] = js.undefined 10 | var timeout: js.UndefOr[Int] = js.undefined 11 | } 12 | object AgentOptions { 13 | def apply( 14 | keepAlive: js.UndefOr[Boolean] = js.undefined, 15 | keepAliveMsecs: js.UndefOr[Int] = js.undefined, 16 | maxSockets: js.UndefOr[Double] = js.undefined, 17 | maxFreeSockets: js.UndefOr[Int] = js.undefined, 18 | timeout: js.UndefOr[Int] = js.undefined 19 | ): AgentOptions = { 20 | val _obj$ = js.Dynamic.literal( 21 | ) 22 | keepAlive.foreach(_v => _obj$.updateDynamic("keepAlive")(_v.asInstanceOf[js.Any])) 23 | keepAliveMsecs.foreach(_v => _obj$.updateDynamic("keepAliveMsecs")(_v.asInstanceOf[js.Any])) 24 | maxSockets.foreach(_v => _obj$.updateDynamic("maxSockets")(_v.asInstanceOf[js.Any])) 25 | maxFreeSockets.foreach(_v => _obj$.updateDynamic("maxFreeSockets")(_v.asInstanceOf[js.Any])) 26 | timeout.foreach(_v => _obj$.updateDynamic("timeout")(_v.asInstanceOf[js.Any])) 27 | _obj$.asInstanceOf[AgentOptions] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Client.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import scala.scalajs.js 4 | 5 | /** NodeJS HTTP Client 6 | */ 7 | @js.native 8 | trait Client extends js.Object { 9 | // /////////////////////////////////////////////////////////////////////////////// 10 | // Properties 11 | // /////////////////////////////////////////////////////////////////////////////// 12 | 13 | /** The client's domain name 14 | */ 15 | def domain: String = js.native 16 | 17 | /** The client's host name 18 | */ 19 | def host: String = js.native 20 | 21 | /** The client's port number 22 | */ 23 | def port: Int = js.native 24 | 25 | /** The client's agent 26 | */ 27 | def agent: Agent = js.native 28 | } 29 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/GetNameOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import scala.scalajs.js 4 | 5 | trait GetNameOptions extends js.Object { 6 | var host: String 7 | var port: js.UndefOr[Int] = js.undefined 8 | var localAddress: js.UndefOr[String] = js.undefined 9 | var family: js.UndefOr[Int] = js.undefined 10 | } 11 | 12 | object GetNameOptions { 13 | def apply( 14 | host: String, 15 | port: js.UndefOr[Int] = js.undefined, 16 | localAddress: js.UndefOr[String] = js.undefined, 17 | family: js.UndefOr[Int] = js.undefined 18 | ): GetNameOptions = { 19 | val _obj$ = js.Dynamic.literal( 20 | "host" -> host.asInstanceOf[js.Any] 21 | ) 22 | port.foreach(_v => _obj$.updateDynamic("port")(_v.asInstanceOf[js.Any])) 23 | localAddress.foreach(_v => _obj$.updateDynamic("localAddress")(_v.asInstanceOf[js.Any])) 24 | family.foreach(_v => _obj$.updateDynamic("family")(_v.asInstanceOf[js.Any])) 25 | _obj$.asInstanceOf[GetNameOptions] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/OutgoingMessage.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import io.scalajs.nodejs.stream 4 | 5 | import scala.scalajs.js 6 | 7 | /** Outgoing Message 8 | */ 9 | @js.native 10 | trait OutgoingMessage extends stream.Writable 11 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/Server.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package http 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | import scala.scalajs.js.| 7 | 8 | /** http.Server - This class inherits from net.Server and has the following additional events 9 | */ 10 | @js.native 11 | @JSImport("http", "Server") 12 | class Server extends net.Server { 13 | var headersTimeout: Int = js.native 14 | var maxHeadersCount: Int | Null = js.native 15 | var timeout: Double = js.native 16 | var keepAliveTimeout: Int = js.native 17 | 18 | def setTimeout(msecs: Double, callback: js.Function): this.type = js.native 19 | def setTimeout(msecs: Double): this.type = js.native 20 | def setTimeout(callback: js.Function): this.type = js.native 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/ServerOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | 7 | trait ServerOptions extends js.Object { 8 | var IncomingMessage: js.UndefOr[js.Function] = js.undefined 9 | var ServerResponse: js.UndefOr[js.Function] = js.undefined 10 | var insecureHTTPParser: js.UndefOr[Boolean] = js.undefined 11 | 12 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 13 | var maxHeaderSize: js.UndefOr[Int] = js.undefined 14 | } 15 | 16 | object ServerOptions { 17 | def apply( 18 | IncomingMessage: js.UndefOr[js.Function] = js.undefined, 19 | ServerResponse: js.UndefOr[js.Function] = js.undefined, 20 | insecureHTTPParser: js.UndefOr[Boolean] = js.undefined, 21 | maxHeaderSize: js.UndefOr[Int] = js.undefined 22 | ): ServerOptions = { 23 | val _obj$ = js.Dynamic.literal( 24 | ) 25 | IncomingMessage.foreach(_v => _obj$.updateDynamic("IncomingMessage")(_v.asInstanceOf[js.Any])) 26 | ServerResponse.foreach(_v => _obj$.updateDynamic("ServerResponse")(_v.asInstanceOf[js.Any])) 27 | insecureHTTPParser.foreach(_v => _obj$.updateDynamic("insecureHTTPParser")(_v.asInstanceOf[js.Any])) 28 | maxHeaderSize.foreach(_v => _obj$.updateDynamic("maxHeaderSize")(_v.asInstanceOf[js.Any])) 29 | _obj$.asInstanceOf[ServerOptions] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http/StatusCodes.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait StatusCodes extends js.Object { 7 | val `100`: String = js.native 8 | val `101`: String = js.native 9 | val `102`: String = js.native 10 | val `103`: String = js.native 11 | val `200`: String = js.native 12 | val `201`: String = js.native 13 | val `202`: String = js.native 14 | val `203`: String = js.native 15 | val `204`: String = js.native 16 | val `205`: String = js.native 17 | val `206`: String = js.native 18 | val `207`: String = js.native 19 | val `208`: String = js.native 20 | val `226`: String = js.native 21 | val `300`: String = js.native 22 | val `301`: String = js.native 23 | val `302`: String = js.native 24 | val `303`: String = js.native 25 | val `304`: String = js.native 26 | val `305`: String = js.native 27 | val `307`: String = js.native 28 | val `308`: String = js.native 29 | val `400`: String = js.native 30 | val `401`: String = js.native 31 | val `402`: String = js.native 32 | val `403`: String = js.native 33 | val `404`: String = js.native 34 | val `405`: String = js.native 35 | val `406`: String = js.native 36 | val `407`: String = js.native 37 | val `408`: String = js.native 38 | val `409`: String = js.native 39 | val `410`: String = js.native 40 | val `411`: String = js.native 41 | val `412`: String = js.native 42 | val `413`: String = js.native 43 | val `414`: String = js.native 44 | val `415`: String = js.native 45 | val `416`: String = js.native 46 | val `417`: String = js.native 47 | val `418`: String = js.native 48 | val `421`: String = js.native 49 | val `422`: String = js.native 50 | val `423`: String = js.native 51 | val `424`: String = js.native 52 | val `425`: String = js.native 53 | val `426`: String = js.native 54 | val `428`: String = js.native 55 | val `429`: String = js.native 56 | val `431`: String = js.native 57 | val `451`: String = js.native 58 | val `500`: String = js.native 59 | val `501`: String = js.native 60 | val `502`: String = js.native 61 | val `503`: String = js.native 62 | val `504`: String = js.native 63 | val `505`: String = js.native 64 | val `506`: String = js.native 65 | val `507`: String = js.native 66 | val `508`: String = js.native 67 | val `509`: String = js.native 68 | val `510`: String = js.native 69 | val `511`: String = js.native 70 | } 71 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/ClientHttp2Session.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait ClientHttp2Session extends Http2Session { 7 | def request(headers: Http2Headers, options: Http2RequestOptions): ClientHttp2Stream = js.native 8 | def request(headers: Http2Headers): ClientHttp2Stream = js.native 9 | } 10 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/ClientHttp2Stream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait ClientHttp2Stream extends Http2Stream 7 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/HasOrigin.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait HasOrigin extends js.Object { 6 | def origin: String 7 | } 8 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.buffer.Buffer 5 | import io.scalajs.nodejs.url.URL 6 | 7 | import scala.scalajs.js 8 | import scala.scalajs.js.annotation.JSImport 9 | import scala.scalajs.js.typedarray.Uint8Array 10 | 11 | @js.native 12 | trait Http2 extends js.Object { 13 | 14 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.ltNodeJs16) 15 | def sensitiveHeaders: js.Symbol = js.native 16 | 17 | def createServer(options: Http2ServerOptions, onRequestHandler: ServerCallback): Http2Server = js.native 18 | def createServer(options: Http2ServerOptions): Http2Server = js.native 19 | 20 | def createSecureServer(options: Http2SecureServerOptions, onRequestHandler: ServerCallback): Http2SecureServer = 21 | js.native 22 | def createSecureServer(options: Http2SecureServerOptions): Http2SecureServer = js.native 23 | 24 | def connect(authority: String, options: Http2ConnectOptions, listener: js.Function): ClientHttp2Session = js.native 25 | def connect(authority: URL, options: Http2ConnectOptions, listener: js.Function): ClientHttp2Session = js.native 26 | 27 | def constants: Http2Constants = js.native 28 | 29 | def getDefaultSettings(): Http2Settings = js.native 30 | def getPackedSettings(settings: Http2Settings): Buffer = js.native 31 | def getUnpackedSettings(buffer: Uint8Array): Http2Settings = js.native 32 | } 33 | 34 | @js.native 35 | @JSImport("http2", JSImport.Namespace) 36 | object Http2 extends Http2 37 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Priority.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2Priority extends js.Object { 6 | var exclusive: js.UndefOr[Boolean] = js.undefined 7 | var parent: js.UndefOr[Int] = js.undefined 8 | var weight: js.UndefOr[Int] = js.undefined 9 | var silent: js.UndefOr[Boolean] = js.undefined 10 | } 11 | object Http2Priority { 12 | def apply( 13 | exclusive: js.UndefOr[Boolean] = js.undefined, 14 | parent: js.UndefOr[Int] = js.undefined, 15 | weight: js.UndefOr[Int] = js.undefined, 16 | silent: js.UndefOr[Boolean] = js.undefined 17 | ): Http2Priority = { 18 | val _obj$ = js.Dynamic.literal( 19 | ) 20 | exclusive.foreach(_v => _obj$.updateDynamic("exclusive")(_v.asInstanceOf[js.Any])) 21 | parent.foreach(_v => _obj$.updateDynamic("parent")(_v.asInstanceOf[js.Any])) 22 | weight.foreach(_v => _obj$.updateDynamic("weight")(_v.asInstanceOf[js.Any])) 23 | silent.foreach(_v => _obj$.updateDynamic("silent")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[Http2Priority] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2PushStreamOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2PushStreamOptions extends js.Object { 6 | var exclusive: js.UndefOr[Boolean] = js.undefined 7 | var parent: js.UndefOr[Int] = js.undefined 8 | } 9 | 10 | object Http2PushStreamOptions { 11 | def apply( 12 | exclusive: js.UndefOr[Boolean] = js.undefined, 13 | parent: js.UndefOr[Int] = js.undefined 14 | ): Http2PushStreamOptions = { 15 | val _obj$ = js.Dynamic.literal( 16 | ) 17 | exclusive.foreach(_v => _obj$.updateDynamic("exclusive")(_v.asInstanceOf[js.Any])) 18 | parent.foreach(_v => _obj$.updateDynamic("parent")(_v.asInstanceOf[js.Any])) 19 | _obj$.asInstanceOf[Http2PushStreamOptions] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2RequestOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2RequestOptions extends js.Object { 6 | var endStream: js.UndefOr[Boolean] = js.undefined 7 | var exclusive: js.UndefOr[Boolean] = js.undefined 8 | var parent: js.UndefOr[Int] = js.undefined 9 | var weight: js.UndefOr[Int] = js.undefined 10 | var waitForTrailers: js.UndefOr[Boolean] = js.undefined 11 | } 12 | object Http2RequestOptions { 13 | def apply( 14 | endStream: js.UndefOr[Boolean] = js.undefined, 15 | exclusive: js.UndefOr[Boolean] = js.undefined, 16 | parent: js.UndefOr[Int] = js.undefined, 17 | weight: js.UndefOr[Int] = js.undefined, 18 | waitForTrailers: js.UndefOr[Boolean] = js.undefined 19 | ): Http2RequestOptions = { 20 | val _obj$ = js.Dynamic.literal( 21 | ) 22 | endStream.foreach(_v => _obj$.updateDynamic("endStream")(_v.asInstanceOf[js.Any])) 23 | exclusive.foreach(_v => _obj$.updateDynamic("exclusive")(_v.asInstanceOf[js.Any])) 24 | parent.foreach(_v => _obj$.updateDynamic("parent")(_v.asInstanceOf[js.Any])) 25 | weight.foreach(_v => _obj$.updateDynamic("weight")(_v.asInstanceOf[js.Any])) 26 | waitForTrailers.foreach(_v => _obj$.updateDynamic("waitForTrailers")(_v.asInstanceOf[js.Any])) 27 | _obj$.asInstanceOf[Http2RequestOptions] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2RespondWithFDOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2RespondWithFDOptions extends js.Object { 6 | var statCheck: js.UndefOr[js.Function] = js.undefined 7 | var waitForTrailers: js.UndefOr[Boolean] = js.undefined 8 | var offset: js.UndefOr[Int] = js.undefined 9 | var length: js.UndefOr[Int] = js.undefined 10 | } 11 | object Http2RespondWithFDOptions { 12 | def apply( 13 | statCheck: js.UndefOr[js.Function] = js.undefined, 14 | waitForTrailers: js.UndefOr[Boolean] = js.undefined, 15 | offset: js.UndefOr[Int] = js.undefined, 16 | length: js.UndefOr[Int] = js.undefined 17 | ): Http2RespondWithFDOptions = { 18 | val _obj$ = js.Dynamic.literal( 19 | ) 20 | statCheck.foreach(_v => _obj$.updateDynamic("statCheck")(_v.asInstanceOf[js.Any])) 21 | waitForTrailers.foreach(_v => _obj$.updateDynamic("waitForTrailers")(_v.asInstanceOf[js.Any])) 22 | offset.foreach(_v => _obj$.updateDynamic("offset")(_v.asInstanceOf[js.Any])) 23 | length.foreach(_v => _obj$.updateDynamic("length")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[Http2RespondWithFDOptions] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2RespondWithFileOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2RespondWithFileOptions extends js.Object { 6 | var statCheck: js.UndefOr[js.Function] = js.undefined 7 | var onError: js.UndefOr[js.Function] = js.undefined 8 | var waitForTrailers: js.UndefOr[Boolean] = js.undefined 9 | var offset: js.UndefOr[Int] = js.undefined 10 | var length: js.UndefOr[Int] = js.undefined 11 | } 12 | 13 | object Http2RespondWithFileOptions { 14 | def apply( 15 | statCheck: js.UndefOr[js.Function] = js.undefined, 16 | onError: js.UndefOr[js.Function] = js.undefined, 17 | waitForTrailers: js.UndefOr[Boolean] = js.undefined, 18 | offset: js.UndefOr[Int] = js.undefined, 19 | length: js.UndefOr[Int] = js.undefined 20 | ): Http2RespondWithFileOptions = { 21 | val _obj$ = js.Dynamic.literal( 22 | ) 23 | statCheck.foreach(_v => _obj$.updateDynamic("statCheck")(_v.asInstanceOf[js.Any])) 24 | onError.foreach(_v => _obj$.updateDynamic("onError")(_v.asInstanceOf[js.Any])) 25 | waitForTrailers.foreach(_v => _obj$.updateDynamic("waitForTrailers")(_v.asInstanceOf[js.Any])) 26 | offset.foreach(_v => _obj$.updateDynamic("offset")(_v.asInstanceOf[js.Any])) 27 | length.foreach(_v => _obj$.updateDynamic("length")(_v.asInstanceOf[js.Any])) 28 | _obj$.asInstanceOf[Http2RespondWithFileOptions] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ResponseOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2ResponseOptions extends js.Object { 6 | var endStream: js.UndefOr[Boolean] = js.undefined 7 | var waitForTrailers: js.UndefOr[Boolean] = js.undefined 8 | } 9 | 10 | object Http2ResponseOptions { 11 | def apply( 12 | endStream: js.UndefOr[Boolean] = js.undefined, 13 | waitForTrailers: js.UndefOr[Boolean] = js.undefined 14 | ): Http2ResponseOptions = { 15 | val _obj$ = js.Dynamic.literal( 16 | ) 17 | endStream.foreach(_v => _obj$.updateDynamic("endStream")(_v.asInstanceOf[js.Any])) 18 | waitForTrailers.foreach(_v => _obj$.updateDynamic("waitForTrailers")(_v.asInstanceOf[js.Any])) 19 | _obj$.asInstanceOf[Http2ResponseOptions] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2SecureServer.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import io.scalajs.nodejs.tls 4 | 5 | import scala.scalajs.js 6 | 7 | @js.native 8 | trait Http2SecureServer extends tls.Server with Http2TimeoutOps 9 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Server.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import io.scalajs.nodejs.net 4 | 5 | import scala.scalajs.js 6 | 7 | @js.native 8 | trait Http2Server extends net.Server with Http2TimeoutOps 9 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerRequest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.{net, tls, stream} 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | import scala.scalajs.js.| 9 | 10 | @js.native 11 | @JSImport("http2", "Http2ServerRequest") 12 | class Http2ServerRequest extends stream.Readable with Http2TimeoutOps { 13 | def authority: String = js.native 14 | 15 | def complete: Boolean = js.native 16 | 17 | @deprecated("Use socket", "Node.js v13.0.0") 18 | def connection: net.Socket | tls.TLSSocket = js.native 19 | 20 | def destroy(error: io.scalajs.nodejs.Error): Unit = js.native 21 | def destroy(): Unit = js.native 22 | 23 | def headers: Http2Headers = js.native 24 | 25 | def httpVersion: String = js.native 26 | 27 | def method: String = js.native 28 | 29 | def rawHeaders: js.Array[String] = js.native 30 | 31 | def rawTrailers: js.Array[String] = js.native 32 | 33 | def scheme: js.Array[String] = js.native 34 | 35 | def socket: net.Socket | tls.TLSSocket = js.native 36 | 37 | def stream: Http2Stream = js.native 38 | 39 | def trailers: js.Object = js.native 40 | 41 | def url: String = js.native 42 | } 43 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2ServerResponse.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.{net, stream, tls} 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | import scala.scalajs.js.| 9 | 10 | @js.native 11 | @JSImport("http2", "Http2ServerResponse") 12 | class Http2ServerResponse extends stream.Writable with Http2TimeoutOps { 13 | def addTrailers(headers: Http2Headers): Unit = js.native 14 | 15 | @deprecated("Use response.socket", "Node.js v13.0.0") 16 | def connection: net.Socket | tls.TLSSocket = js.native 17 | def socket: net.Socket | tls.TLSSocket = js.native 18 | def stream: Http2Stream = js.native 19 | 20 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.ltNodeJs16) 21 | def req: Http2ServerRequest = js.native 22 | 23 | def writeHead(statusCode: Int, statusMessage: String, http2Headers: Http2Headers): Unit = js.native 24 | def writeHead(statusCode: Int, http2Headers: Http2Headers): Unit = js.native 25 | def writeHead(statusCode: Int, statusMessage: String): Unit = js.native 26 | def writeHead(statusCode: Int): Unit = js.native 27 | 28 | def writeContinue(): Unit = js.native 29 | 30 | def createPushResponse(headers: Http2Headers, 31 | callback: js.Function2[io.scalajs.nodejs.Error, ServerHttp2Stream, Any] 32 | ): Unit = js.native 33 | 34 | def getHeader(name: String): String = js.native 35 | def getHeaderNames(name: String): js.Array[String] = js.native 36 | def getHeaders(): Http2Headers = js.native 37 | def hasHeader(name: String): Boolean = js.native 38 | def removeHeader(name: String): Unit = js.native 39 | def setHeader(name: String, value: String): Unit = js.native 40 | def setHeader(name: String, value: js.Array[String]): Unit = js.native 41 | 42 | @deprecated("Use writableEnd", "Node.js v13.4.0, v12.16.0") 43 | def finished: Boolean = js.native 44 | def headersSent: Boolean = js.native 45 | def sendDate: Boolean = js.native 46 | 47 | def statusCode: Int = js.native 48 | def statusMessage: String = js.native 49 | } 50 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2SessionState.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait Http2SessionState extends js.Object { 7 | def effectiveLocalWindowSize: Int = js.native 8 | def effectiveRecvDataLength: Int = js.native 9 | def nextStreamID: Int = js.native 10 | def localWindowSize: Int = js.native 11 | def lastProcStreamID: Int = js.native 12 | def remoteWindowSize: Int = js.native 13 | def outboundQueueSize: Int = js.native 14 | def deflateDynamicTableSize: Int = js.native 15 | def inflateDynamicTableSize: Int = js.native 16 | } 17 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Settings.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | trait Http2Settings extends js.Object { 6 | var headerTableSize: js.UndefOr[Int] = js.undefined 7 | var enablePush: js.UndefOr[Boolean] = js.undefined 8 | var initialWindowSize: js.UndefOr[Int] = js.undefined 9 | var maxFrameSize: js.UndefOr[Int] = js.undefined 10 | var maxConcurrentStreams: js.UndefOr[Int] = js.undefined 11 | var maxHeaderListSize: js.UndefOr[Int] = js.undefined 12 | var enableConnectProtocol: js.UndefOr[Int] = js.undefined 13 | } 14 | 15 | object Http2Settings { 16 | def apply( 17 | headerTableSize: js.UndefOr[Int] = js.undefined, 18 | enablePush: js.UndefOr[Boolean] = js.undefined, 19 | initialWindowSize: js.UndefOr[Int] = js.undefined, 20 | maxFrameSize: js.UndefOr[Int] = js.undefined, 21 | maxConcurrentStreams: js.UndefOr[Int] = js.undefined, 22 | maxHeaderListSize: js.UndefOr[Int] = js.undefined, 23 | enableConnectProtocol: js.UndefOr[Int] = js.undefined 24 | ): Http2Settings = { 25 | val _obj$ = js.Dynamic.literal( 26 | ) 27 | headerTableSize.foreach(_v => _obj$.updateDynamic("headerTableSize")(_v.asInstanceOf[js.Any])) 28 | enablePush.foreach(_v => _obj$.updateDynamic("enablePush")(_v.asInstanceOf[js.Any])) 29 | initialWindowSize.foreach(_v => _obj$.updateDynamic("initialWindowSize")(_v.asInstanceOf[js.Any])) 30 | maxFrameSize.foreach(_v => _obj$.updateDynamic("maxFrameSize")(_v.asInstanceOf[js.Any])) 31 | maxConcurrentStreams.foreach(_v => _obj$.updateDynamic("maxConcurrentStreams")(_v.asInstanceOf[js.Any])) 32 | maxHeaderListSize.foreach(_v => _obj$.updateDynamic("maxHeaderListSize")(_v.asInstanceOf[js.Any])) 33 | enableConnectProtocol.foreach(_v => _obj$.updateDynamic("enableConnectProtocol")(_v.asInstanceOf[js.Any])) 34 | _obj$.asInstanceOf[Http2Settings] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2Stream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import io.scalajs.nodejs.stream 4 | 5 | import scala.scalajs.js 6 | 7 | @js.native 8 | trait Http2Stream extends stream.Duplex { 9 | def aborted: Boolean = js.native 10 | 11 | def bufferSize: Int = js.native 12 | 13 | def close(code: Int, callback: js.Function): Unit = js.native 14 | def close(code: Int): Unit = js.native 15 | 16 | def closed: Boolean = js.native 17 | 18 | def endAfterHeaders: Boolean = js.native 19 | 20 | def id: js.UndefOr[Int] = js.native 21 | 22 | def pending: Boolean = js.native 23 | 24 | def priority(options: Http2Priority): Unit = js.native 25 | 26 | def rstCode: Int = js.native 27 | 28 | def sentHeaders: Http2Headers = js.native 29 | 30 | def sentInfoHeaders: js.Array[Http2Headers] = js.native 31 | 32 | def sentTrailers: Http2Headers = js.native 33 | 34 | def session: Http2Session = js.native 35 | 36 | def setTimeout(msecs: Int, callback: js.Function): Unit = js.native 37 | 38 | def state: Http2StreamState = js.native 39 | 40 | def sendTrailers(headers: Http2Headers): Unit = js.native 41 | } 42 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2StreamState.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait Http2StreamState extends js.Object { 7 | def localWindowSize: Int = js.native 8 | def state: Int = js.native 9 | def localClose: Boolean = js.native 10 | def remoteClose: Boolean = js.native 11 | def sumDependencyWeight: Int = js.native 12 | def weight: Int = js.native 13 | } 14 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/Http2TimeoutOps.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait Http2TimeoutOps extends js.Object { 7 | def setTimeout(msecs: Int, callback: js.Function): this.type = js.native 8 | def setTimeout(msecs: Int): this.type = js.native 9 | def setTimeout(callback: js.Function): this.type = js.native 10 | def setTimeout(): this.type = js.native 11 | } 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait ServerHttp2Session extends Http2Session { 7 | def altsvc(alt: String, stream: Int): Unit = js.native 8 | def altsvc(alt: String, origin: Origin): Unit = js.native 9 | 10 | def origin(origins: Origin*): Unit = js.native 11 | } 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Stream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.http2 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait ServerHttp2Stream extends Http2Stream { 7 | def additionalHeaders(headers: Http2Headers): Unit = js.native 8 | 9 | def headersSent: Boolean = js.native 10 | 11 | def pushAllowed: Boolean = js.native 12 | 13 | def pushStream(headers: Http2Headers, 14 | options: Http2PushStreamOptions, 15 | callback: js.Function3[io.scalajs.nodejs.Error, ServerHttp2Stream, Http2Headers, Any] 16 | ): Unit = 17 | js.native 18 | def pushStream(headers: Http2Headers, 19 | callback: js.Function3[io.scalajs.nodejs.Error, ServerHttp2Stream, Http2Headers, Any] 20 | ): Unit = 21 | js.native 22 | 23 | def respond(headers: Http2Headers, options: Http2ResponseOptions): Unit = js.native 24 | def respond(headers: Http2Headers): Unit = js.native 25 | def respond(): Unit = js.native 26 | 27 | def respondWithFD(fd: Int, headers: Http2Headers, options: Http2RespondWithFDOptions): Unit = js.native 28 | def respondWithFD(fd: Int, headers: Http2Headers): Unit = js.native 29 | def respondWithFD(fd: Int): Unit = js.native 30 | 31 | def respondWithFile(path: Path, headers: Http2Headers, options: Http2RespondWithFileOptions): Unit = js.native 32 | def respondWithFile(path: Path, headers: Http2Headers): Unit = js.native 33 | def respondWithFile(path: Path): Unit = js.native 34 | } 35 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/Agent.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.https 2 | 3 | import io.scalajs.nodejs 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | /** HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a separate module. 9 | */ 10 | @js.native 11 | @JSImport("https", "Agent") 12 | class Agent() extends nodejs.http.Agent { 13 | def this(options: AgentOptions) = this() 14 | } 15 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/Server.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package https 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** This class is a subclass of tls.Server and emits events same as http.Server. See http.Server for more information. 8 | */ 9 | @js.native 10 | @JSImport("https", "Server") 11 | class Server extends tls.Server { 12 | def headersTimeout: Int = js.native 13 | 14 | def maxHeaderCount: Int = js.native 15 | def timeout: Int = js.native 16 | def keepAliveTimeout: Int = js.native 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/https/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.http.{RequestOptions, ServerResponse} 5 | import io.scalajs.util.PromiseHelper._ 6 | import io.scalajs.nodejs.url.URL 7 | 8 | import scala.concurrent.Future 9 | 10 | /** https package object 11 | */ 12 | package object https { 13 | 14 | /** Https Extensions 15 | */ 16 | implicit final class HttpExtensions(private val https: Https) extends AnyVal { 17 | 18 | /** Like http.get() but for HTTPS. 19 | */ 20 | @inline 21 | def getFuture(options: RequestOptions): Future[ServerResponse] = { 22 | promiseCallback1[ServerResponse](https.get(options, _)) 23 | } 24 | 25 | /** Like http.get() but for HTTPS. 26 | */ 27 | @inline 28 | def getFuture(url: String): Future[ServerResponse] = { 29 | promiseCallback1[ServerResponse](https.get(url, _)) 30 | } 31 | 32 | /** Makes a request to a secure web server. 33 | */ 34 | @inline 35 | def requestFuture(options: RequestOptions): Future[ServerResponse] = { 36 | promiseCallback1[ServerResponse](https.request(options, _)) 37 | } 38 | 39 | @inline 40 | def requestFuture(url: String): Future[ServerResponse] = { 41 | promiseCallback1[ServerResponse](https.request(url, _)) 42 | } 43 | @inline 44 | def requestFuture(url: URL): Future[ServerResponse] = { 45 | promiseCallback1[ServerResponse](https.request(url, _)) 46 | } 47 | @inline 48 | def requestFuture(url: String, options: RequestOptions): Future[ServerResponse] = { 49 | promiseCallback1[ServerResponse](https.request(url, options, _)) 50 | } 51 | @inline 52 | def requestFuture(url: URL, options: RequestOptions): Future[ServerResponse] = { 53 | promiseCallback1[ServerResponse](https.request(url, options, _)) 54 | } 55 | } 56 | 57 | implicit final class AgentExtensions[T <: Agent](private val instance: T) extends AnyVal { 58 | @inline def onKeylog(handler: (io.scalajs.nodejs.buffer.Buffer, tls.TLSSocket) => Any): T = 59 | instance.on("keylog", handler) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/module/Module.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.module 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.Require 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | 9 | @js.native 10 | @JSImport("module", JSImport.Namespace) 11 | object Module extends Module 12 | 13 | @js.native 14 | trait Module extends js.Object { 15 | var builtinModules: js.Array[String] = js.native 16 | 17 | def createRequire(filename: String): Require = js.native 18 | 19 | def createRequire(filename: io.scalajs.nodejs.url.URL): Require = js.native 20 | 21 | def syncBuiltinESMExports(): Unit = js.native 22 | 23 | @deprecated("Use createRequire", "Node.js v12.2.0") 24 | def createRequireFromPath(filename: String): Require = js.native 25 | 26 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 27 | def findSourceMap(path: String): SourceMap = js.native 28 | 29 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 30 | def findSourceMap(path: String, error: io.scalajs.nodejs.Error): SourceMap = js.native 31 | } 32 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/module/SourceMap.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.module 2 | 3 | import com.thoughtworks.enableMembersIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 10 | @JSImport("module", "SourceMap") 11 | class SourceMap(payload: SourceMapPayload) extends js.Object { 12 | def payload: SourceMapPayload = js.native 13 | def findEntry(lineNumber: Int, columnNumber: Int): SourceMapEntry = js.native 14 | } 15 | 16 | trait SourceMapPayload extends js.Object { 17 | var file: String 18 | var version: Double 19 | var sources: js.Array[String] 20 | var sourcesContent: js.Array[String] 21 | var names: js.Array[String] 22 | var mappings: String 23 | var sourceRoot: String 24 | } 25 | 26 | object SourceMapPayload { 27 | def apply( 28 | file: String, 29 | version: Double, 30 | sources: js.Array[String], 31 | sourcesContent: js.Array[String], 32 | names: js.Array[String], 33 | mappings: String, 34 | sourceRoot: String 35 | ): SourceMapPayload = { 36 | val _obj$ = js.Dynamic.literal( 37 | "file" -> file.asInstanceOf[js.Any], 38 | "version" -> version.asInstanceOf[js.Any], 39 | "sources" -> sources.asInstanceOf[js.Any], 40 | "sourcesContent" -> sourcesContent.asInstanceOf[js.Any], 41 | "names" -> names.asInstanceOf[js.Any], 42 | "mappings" -> mappings.asInstanceOf[js.Any], 43 | "sourceRoot" -> sourceRoot.asInstanceOf[js.Any] 44 | ) 45 | _obj$.asInstanceOf[SourceMapPayload] 46 | } 47 | } 48 | 49 | trait SourceMapEntry extends js.Object { 50 | var generatedLine: Int 51 | var generatedColumn: Int 52 | var originalSource: String 53 | var originalLine: Int 54 | var originalColumn: Int 55 | } 56 | object SourceMapEntry { 57 | def apply( 58 | generatedLine: Int, 59 | generatedColumn: Int, 60 | originalSource: String, 61 | originalLine: Int, 62 | originalColumn: Int 63 | ): SourceMapEntry = { 64 | val _obj$ = js.Dynamic.literal( 65 | "generatedLine" -> generatedLine.asInstanceOf[js.Any], 66 | "generatedColumn" -> generatedColumn.asInstanceOf[js.Any], 67 | "originalSource" -> originalSource.asInstanceOf[js.Any], 68 | "originalLine" -> originalLine.asInstanceOf[js.Any], 69 | "originalColumn" -> originalColumn.asInstanceOf[js.Any] 70 | ) 71 | _obj$.asInstanceOf[SourceMapEntry] 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/Address.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import scala.scalajs.js 4 | 5 | /** Server IP Address 6 | */ 7 | @js.native 8 | trait Address extends js.Object { 9 | var address: js.UndefOr[String] = js.native 10 | var family: js.UndefOr[String] = js.native 11 | var port: js.UndefOr[Int] = js.native 12 | } 13 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/BlockList.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import com.thoughtworks.enableMembersIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | @JSImport("net", "BlockList") 10 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 11 | class BlockList() extends js.Object { 12 | def addAddress(address: String, `type`: String): Unit = js.native 13 | def addAddress(address: SocketAddress, `type`: String): Unit = js.native 14 | def addAddress(address: String): Unit = js.native 15 | def addAddress(address: SocketAddress): Unit = js.native 16 | 17 | def addRange(start: SocketAddress, end: SocketAddress, `type`: String): Unit = js.native 18 | def addRange(start: SocketAddress, end: String, `type`: String): Unit = js.native 19 | def addRange(start: String, end: SocketAddress, `type`: String): Unit = js.native 20 | def addRange(start: String, end: String, `type`: String): Unit = js.native 21 | def addRange(start: SocketAddress, end: SocketAddress): Unit = js.native 22 | def addRange(start: SocketAddress, end: String): Unit = js.native 23 | def addRange(start: String, end: SocketAddress): Unit = js.native 24 | def addRange(start: String, end: String): Unit = js.native 25 | 26 | def addSubnet(net: SocketAddress, prefix: Int, `type`: String): Unit = js.native 27 | def addSubnet(net: String, prefix: Int, `type`: String): Unit = js.native 28 | def addSubnet(net: SocketAddress, prefix: Int): Unit = js.native 29 | def addSubnet(net: String, prefix: Int): Unit = js.native 30 | 31 | def check(address: SocketAddress, `type`: String): Boolean = js.native 32 | def check(address: String, `type`: String): Boolean = js.native 33 | def check(address: SocketAddress): Boolean = js.native 34 | def check(address: String): Boolean = js.native 35 | 36 | def rules: js.Array[String] = js.native 37 | } 38 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/ListenerOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import scala.scalajs.js 4 | 5 | trait ListenerOptions extends js.Object { 6 | var host: js.UndefOr[String] = js.undefined 7 | var port: js.UndefOr[Int] = js.undefined 8 | var path: js.UndefOr[String] = js.undefined 9 | var backlog: js.UndefOr[Int] = js.undefined 10 | var exclusive: js.UndefOr[Boolean] = js.undefined 11 | var readableAll: js.UndefOr[Boolean] = js.undefined 12 | var writableAll: js.UndefOr[Boolean] = js.undefined 13 | var ipv6Only: js.UndefOr[Boolean] = js.undefined 14 | } 15 | object ListenerOptions { 16 | def apply( 17 | host: js.UndefOr[String] = js.undefined, 18 | port: js.UndefOr[Int] = js.undefined, 19 | path: js.UndefOr[String] = js.undefined, 20 | backlog: js.UndefOr[Int] = js.undefined, 21 | exclusive: js.UndefOr[Boolean] = js.undefined, 22 | readableAll: js.UndefOr[Boolean] = js.undefined, 23 | writableAll: js.UndefOr[Boolean] = js.undefined, 24 | ipv6Only: js.UndefOr[Boolean] = js.undefined 25 | ): ListenerOptions = { 26 | val _obj$ = js.Dynamic.literal( 27 | ) 28 | host.foreach(_v => _obj$.updateDynamic("host")(_v.asInstanceOf[js.Any])) 29 | port.foreach(_v => _obj$.updateDynamic("port")(_v.asInstanceOf[js.Any])) 30 | path.foreach(_v => _obj$.updateDynamic("path")(_v.asInstanceOf[js.Any])) 31 | backlog.foreach(_v => _obj$.updateDynamic("backlog")(_v.asInstanceOf[js.Any])) 32 | exclusive.foreach(_v => _obj$.updateDynamic("exclusive")(_v.asInstanceOf[js.Any])) 33 | readableAll.foreach(_v => _obj$.updateDynamic("readableAll")(_v.asInstanceOf[js.Any])) 34 | writableAll.foreach(_v => _obj$.updateDynamic("writableAll")(_v.asInstanceOf[js.Any])) 35 | ipv6Only.foreach(_v => _obj$.updateDynamic("ipv6Only")(_v.asInstanceOf[js.Any])) 36 | _obj$.asInstanceOf[ListenerOptions] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/ServerOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import scala.scalajs.js 4 | 5 | trait ServerOptions extends js.Object { 6 | var allowHalfOpen: js.UndefOr[Boolean] = js.undefined 7 | var pauseOnConnect: js.UndefOr[Boolean] = js.undefined 8 | } 9 | object ServerOptions { 10 | def apply( 11 | allowHalfOpen: js.UndefOr[Boolean] = js.undefined, 12 | pauseOnConnect: js.UndefOr[Boolean] = js.undefined 13 | ): ServerOptions = { 14 | val _obj$ = js.Dynamic.literal( 15 | ) 16 | allowHalfOpen.foreach(_v => _obj$.updateDynamic("allowHalfOpen")(_v.asInstanceOf[js.Any])) 17 | pauseOnConnect.foreach(_v => _obj$.updateDynamic("pauseOnConnect")(_v.asInstanceOf[js.Any])) 18 | _obj$.asInstanceOf[ServerOptions] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/SocketAddress.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import com.thoughtworks.enableMembersIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | @JSImport("net", "SocketAddress") 10 | @enableMembersIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 11 | class SocketAddress(options: SocketAddressOptions) extends js.Object { 12 | def this() = this(null) 13 | 14 | var address: String = js.native 15 | var family: String = js.native 16 | var flowlabel: Int = js.native 17 | var port: Int = js.native 18 | } 19 | 20 | trait SocketAddressOptions extends js.Object { 21 | var address: js.UndefOr[String] = js.undefined 22 | var family: js.UndefOr[String] = js.undefined 23 | var flowlabel: js.UndefOr[Int] = js.undefined 24 | var port: js.UndefOr[Int] = js.undefined 25 | } 26 | object SocketAddressOptions { 27 | def apply( 28 | address: js.UndefOr[String] = js.undefined, 29 | family: js.UndefOr[String] = js.undefined, 30 | flowlabel: js.UndefOr[Int] = js.undefined, 31 | port: js.UndefOr[Int] = js.undefined 32 | ): SocketAddressOptions = { 33 | val _obj$ = js.Dynamic.literal( 34 | ) 35 | address.foreach(_v => _obj$.updateDynamic("address")(_v.asInstanceOf[js.Any])) 36 | family.foreach(_v => _obj$.updateDynamic("family")(_v.asInstanceOf[js.Any])) 37 | flowlabel.foreach(_v => _obj$.updateDynamic("flowlabel")(_v.asInstanceOf[js.Any])) 38 | port.foreach(_v => _obj$.updateDynamic("port")(_v.asInstanceOf[js.Any])) 39 | _obj$.asInstanceOf[SocketAddressOptions] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/net/SocketOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.net 2 | 3 | import io.scalajs.nodejs.FileDescriptor 4 | 5 | import scala.scalajs.js 6 | 7 | trait SocketOptions extends js.Object { 8 | 9 | /** fd allows you to specify the existing file descriptor of socket. Set readable and/or writable to true to allow 10 | * reads and/or writes on this socket (NOTE: Works only when fd is passed). About allowHalfOpen, refer to 11 | * createServer() and 'end' event. 12 | */ 13 | var fd: js.UndefOr[FileDescriptor] = js.undefined 14 | var allowHalfOpen: js.UndefOr[Boolean] = js.undefined 15 | var readable: js.UndefOr[Boolean] = js.undefined 16 | var writable: js.UndefOr[Boolean] = js.undefined 17 | } 18 | 19 | object SocketOptions { 20 | def apply( 21 | fd: js.UndefOr[FileDescriptor] = js.undefined, 22 | allowHalfOpen: js.UndefOr[Boolean] = js.undefined, 23 | readable: js.UndefOr[Boolean] = js.undefined, 24 | writable: js.UndefOr[Boolean] = js.undefined 25 | ): SocketOptions = { 26 | val _obj$ = js.Dynamic.literal( 27 | ) 28 | fd.foreach(_v => _obj$.updateDynamic("fd")(_v.asInstanceOf[js.Any])) 29 | allowHalfOpen.foreach(_v => _obj$.updateDynamic("allowHalfOpen")(_v.asInstanceOf[js.Any])) 30 | readable.foreach(_v => _obj$.updateDynamic("readable")(_v.asInstanceOf[js.Any])) 31 | writable.foreach(_v => _obj$.updateDynamic("writable")(_v.asInstanceOf[js.Any])) 32 | _obj$.asInstanceOf[SocketOptions] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/os/CPUInfo.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.os 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait CPUInfo extends js.Object { 7 | val model: String = js.native 8 | val speed: Double = js.native 9 | val times: CPUTime = js.native 10 | } 11 | 12 | @js.native 13 | trait CPUTime extends js.Object { 14 | val user: Double = js.native 15 | val nice: Double = js.native 16 | val sys: Double = js.native 17 | val idle: Double = js.native 18 | val irq: Double = js.native 19 | } 20 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/os/NetworkInterface.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.os 2 | 3 | import scala.scalajs.js 4 | 5 | /** Represents a Network Interface 6 | */ 7 | trait NetworkInterface extends js.Object { 8 | var address: String 9 | var netmask: String 10 | var family: String 11 | var mac: String 12 | var scopeid: js.UndefOr[Int] = js.undefined 13 | var internal: Boolean 14 | } 15 | object NetworkInterface { 16 | def apply( 17 | address: String, 18 | netmask: String, 19 | family: String, 20 | mac: String, 21 | internal: Boolean, 22 | scopeid: js.UndefOr[Int] = js.undefined 23 | ): NetworkInterface = { 24 | val _obj$ = js.Dynamic.literal( 25 | "address" -> address.asInstanceOf[js.Any], 26 | "netmask" -> netmask.asInstanceOf[js.Any], 27 | "family" -> family.asInstanceOf[js.Any], 28 | "mac" -> mac.asInstanceOf[js.Any], 29 | "internal" -> internal.asInstanceOf[js.Any] 30 | ) 31 | scopeid.foreach(_v => _obj$.updateDynamic("scopeid")(_v.asInstanceOf[js.Any])) 32 | _obj$.asInstanceOf[NetworkInterface] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/os/UserInfoObject.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.os 2 | 3 | import io.scalajs.nodejs.{GID, UID} 4 | 5 | import scala.scalajs.js 6 | 7 | /** User Information Object 8 | * @example 9 | * {{{{"uid":501,"gid":20,"username":"ldaniels","homedir":"/Users/ldaniels","shell":"/bin/bash"}}} } 10 | */ 11 | trait UserInfoObject extends js.Object { 12 | var uid: UID 13 | var gid: GID 14 | var username: String 15 | var homedir: String 16 | var shell: String 17 | } 18 | 19 | object UserInfoObject { 20 | def apply( 21 | uid: UID, 22 | gid: GID, 23 | username: String, 24 | homedir: String, 25 | shell: String 26 | ): UserInfoObject = { 27 | val _obj$ = js.Dynamic.literal( 28 | "uid" -> uid.asInstanceOf[js.Any], 29 | "gid" -> gid.asInstanceOf[js.Any], 30 | "username" -> username.asInstanceOf[js.Any], 31 | "homedir" -> homedir.asInstanceOf[js.Any], 32 | "shell" -> shell.asInstanceOf[js.Any] 33 | ) 34 | _obj$.asInstanceOf[UserInfoObject] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/os/UserInfoOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.os 2 | 3 | import scala.scalajs.js 4 | 5 | trait UserInfoOptions extends js.Object { 6 | var encoding: js.UndefOr[String] = js.undefined 7 | var username: js.UndefOr[String] = js.undefined 8 | var shell: js.UndefOr[String] = js.undefined 9 | var homedir: js.UndefOr[String] = js.undefined 10 | } 11 | object UserInfoOptions { 12 | def apply( 13 | encoding: js.UndefOr[String] = js.undefined, 14 | username: js.UndefOr[String] = js.undefined, 15 | shell: js.UndefOr[String] = js.undefined, 16 | homedir: js.UndefOr[String] = js.undefined 17 | ): UserInfoOptions = { 18 | val _obj$ = js.Dynamic.literal( 19 | ) 20 | encoding.foreach(_v => _obj$.updateDynamic("encoding")(_v.asInstanceOf[js.Any])) 21 | username.foreach(_v => _obj$.updateDynamic("username")(_v.asInstanceOf[js.Any])) 22 | shell.foreach(_v => _obj$.updateDynamic("shell")(_v.asInstanceOf[js.Any])) 23 | homedir.foreach(_v => _obj$.updateDynamic("homedir")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[UserInfoOptions] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/path/PathObject.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.path 2 | 3 | import scala.scalajs.js 4 | 5 | trait PathObject extends js.Object { 6 | var root: js.UndefOr[String] = js.undefined 7 | var dir: js.UndefOr[String] = js.undefined 8 | var base: js.UndefOr[String] = js.undefined 9 | var ext: js.UndefOr[String] = js.undefined 10 | var name: js.UndefOr[String] = js.undefined 11 | } 12 | object PathObject { 13 | def apply( 14 | root: js.UndefOr[String] = js.undefined, 15 | dir: js.UndefOr[String] = js.undefined, 16 | base: js.UndefOr[String] = js.undefined, 17 | ext: js.UndefOr[String] = js.undefined, 18 | name: js.UndefOr[String] = js.undefined 19 | ): PathObject = { 20 | val _obj$ = js.Dynamic.literal( 21 | ) 22 | root.foreach(_v => _obj$.updateDynamic("root")(_v.asInstanceOf[js.Any])) 23 | dir.foreach(_v => _obj$.updateDynamic("dir")(_v.asInstanceOf[js.Any])) 24 | base.foreach(_v => _obj$.updateDynamic("base")(_v.asInstanceOf[js.Any])) 25 | ext.foreach(_v => _obj$.updateDynamic("ext")(_v.asInstanceOf[js.Any])) 26 | name.foreach(_v => _obj$.updateDynamic("name")(_v.asInstanceOf[js.Any])) 27 | _obj$.asInstanceOf[PathObject] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/perf_hooks/PerfHooks.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.perf_hooks 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | trait PerfHooks extends js.Object { 10 | def constants: Constants = js.native 11 | 12 | def eventLoopUtilization(utilization1: EventLoopUtilizationResult, 13 | utilization2: EventLoopUtilizationResult 14 | ): EventLoopUtilizationResult = js.native 15 | 16 | def monitorEventLoopDelay(): Histogram = js.native 17 | def monitorEventLoopDelay(options: MonitorEventLoopDelayOptions): Histogram = js.native 18 | 19 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs16) 20 | def performance: Performance = js.native 21 | } 22 | 23 | trait EventLoopUtilizationResult extends js.Object { 24 | var idle: Double 25 | var active: Double 26 | var utilization: Double 27 | } 28 | object EventLoopUtilizationResult { 29 | def apply( 30 | idle: Double, 31 | active: Double, 32 | utilization: Double 33 | ): EventLoopUtilizationResult = { 34 | val _obj$ = js.Dynamic.literal( 35 | "idle" -> idle.asInstanceOf[js.Any], 36 | "active" -> active.asInstanceOf[js.Any], 37 | "utilization" -> utilization.asInstanceOf[js.Any] 38 | ) 39 | _obj$.asInstanceOf[EventLoopUtilizationResult] 40 | } 41 | } 42 | 43 | trait PerformanceResultJson extends js.Object { 44 | var nodeTiming: PerformanceNodeTiming 45 | var timeOrigin: Double 46 | var eventLoopUtilization: EventLoopUtilizationResult 47 | } 48 | object PerformanceResultJson { 49 | def apply( 50 | nodeTiming: PerformanceNodeTiming, 51 | timeOrigin: Double, 52 | eventLoopUtilization: EventLoopUtilizationResult 53 | ): PerformanceResultJson = { 54 | val _obj$ = js.Dynamic.literal( 55 | "nodeTiming" -> nodeTiming.asInstanceOf[js.Any], 56 | "timeOrigin" -> timeOrigin.asInstanceOf[js.Any], 57 | "eventLoopUtilization" -> eventLoopUtilization.asInstanceOf[js.Any] 58 | ) 59 | _obj$.asInstanceOf[PerformanceResultJson] 60 | } 61 | } 62 | 63 | @js.native 64 | @JSImport("perf_hooks", JSImport.Namespace) 65 | object PerfHooks extends PerfHooks 66 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/process/Environment.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.process 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSBracketAccess 5 | 6 | @js.native 7 | trait Environment extends js.Object { 8 | // common for unix-like and windows 9 | def PATH: String = js.native 10 | 11 | // unix-like 12 | def `_`: js.UndefOr[String] = js.native 13 | def HOME: js.UndefOr[String] = js.native 14 | def PWD: js.UndefOr[String] = js.native 15 | def LD_LIBRARY_PATH: js.UndefOr[String] = js.native 16 | def LIBPATH: js.UndefOr[String] = js.native 17 | def SHLIB_PATH: js.UndefOr[String] = js.native 18 | def LANG: js.UndefOr[String] = js.native 19 | def TZ: js.UndefOr[String] = js.native 20 | def DISPLAY: js.UndefOr[String] = js.native 21 | def PS1: js.UndefOr[String] = js.native 22 | def OSTYPE: js.UndefOr[String] = js.native 23 | def TERM: js.UndefOr[String] = js.native 24 | def SHELL: js.UndefOr[String] = js.native 25 | def USER: js.UndefOr[String] = js.native 26 | def EDITOR: js.UndefOr[String] = js.native 27 | def SHLVL: js.UndefOr[String] = js.native 28 | def LOGNAME: js.UndefOr[String] = js.native 29 | 30 | @JSBracketAccess 31 | def apply(key: String): js.UndefOr[String] = js.native 32 | 33 | @JSBracketAccess 34 | def update(key: String, value: String): Unit = js.native 35 | } 36 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/querystring/QueryDecodeOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.querystring 2 | 3 | import scala.scalajs.js 4 | 5 | trait QueryDecodeOptions extends js.Object { 6 | 7 | /** The function to use when decoding percent-encoded characters in the query string. Defaults to 8 | * querystring.unescape(). 9 | */ 10 | var decodeURIComponent: js.UndefOr[js.Function] = js.undefined 11 | 12 | /** Specifies the maximum number of keys to parse. Defaults to 1000. Specify 0 to remove key counting limitations. The 13 | * querystring.parse() method parses a URL query string into a collection of key and value pairs. 14 | */ 15 | var maxKeys: js.UndefOr[Int] = js.undefined 16 | } 17 | 18 | object QueryDecodeOptions { 19 | def apply( 20 | decodeURIComponent: js.UndefOr[js.Function] = js.undefined, 21 | maxKeys: js.UndefOr[Int] = js.undefined 22 | ): QueryDecodeOptions = { 23 | val _obj$ = js.Dynamic.literal( 24 | ) 25 | decodeURIComponent.foreach(_v => _obj$.updateDynamic("decodeURIComponent")(_v.asInstanceOf[js.Any])) 26 | maxKeys.foreach(_v => _obj$.updateDynamic("maxKeys")(_v.asInstanceOf[js.Any])) 27 | _obj$.asInstanceOf[QueryDecodeOptions] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/querystring/QueryEncodeOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.querystring 2 | 3 | import scala.scalajs.js 4 | 5 | trait QueryEncodeOptions extends js.Object { 6 | 7 | /** The function to use when converting URL-unsafe characters to percent-encoding in the query string. Defaults to 8 | * querystring.escape(). 9 | */ 10 | var encodeURIComponent: js.UndefOr[js.Function] = js.undefined 11 | } 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/querystring/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | /** query string package object 6 | */ 7 | package object querystring { 8 | 9 | /** Query String Enrichment 10 | * @param qs 11 | * the given [[QueryString]] 12 | */ 13 | implicit final class QueryStringEnrichment(private val qs: QueryString) extends AnyVal { 14 | @inline 15 | def parseAs[T <: js.Object](str: String, sep: String, eq: String, options: QueryDecodeOptions): T = { 16 | qs.parse(str, sep, eq, options).asInstanceOf[T] 17 | } 18 | 19 | @inline 20 | def parseAs[T <: js.Object](str: String, sep: String, eq: String): T = { 21 | qs.parse(str, sep, eq).asInstanceOf[T] 22 | } 23 | 24 | @inline 25 | def parseAs[T <: js.Object](str: String, sep: String): T = { 26 | qs.parse(str, sep).asInstanceOf[T] 27 | } 28 | 29 | @inline 30 | def parseAs[T <: js.Object](str: String): T = { 31 | qs.parse(str).asInstanceOf[T] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/readline/ReadlineOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.readline 2 | 3 | import io.scalajs.nodejs.stream.{IReadable, IWritable} 4 | 5 | import scala.scalajs.js 6 | 7 | trait ReadlineOptions extends js.Object { 8 | var input: js.UndefOr[IReadable] = js.undefined 9 | var output: js.UndefOr[IWritable] = js.undefined 10 | var completer: js.UndefOr[js.Function] = js.undefined 11 | var terminal: js.UndefOr[Boolean] = js.undefined 12 | var historySize: js.UndefOr[Int] = js.undefined 13 | var prompt: js.UndefOr[String] = js.undefined 14 | var crlfDelay: js.UndefOr[Double] = js.undefined 15 | var removeHistoryDuplicates: js.UndefOr[Boolean] = js.undefined 16 | var escapeCodeTimeout: js.UndefOr[Double] = js.undefined 17 | var tabSize: js.UndefOr[Int] = js.undefined 18 | } 19 | 20 | object ReadlineOptions { 21 | def apply( 22 | input: js.UndefOr[IReadable] = js.undefined, 23 | output: js.UndefOr[IWritable] = js.undefined, 24 | completer: js.UndefOr[js.Function] = js.undefined, 25 | terminal: js.UndefOr[Boolean] = js.undefined, 26 | historySize: js.UndefOr[Int] = js.undefined, 27 | prompt: js.UndefOr[String] = js.undefined, 28 | crlfDelay: js.UndefOr[Double] = js.undefined, 29 | removeHistoryDuplicates: js.UndefOr[Boolean] = js.undefined, 30 | escapeCodeTimeout: js.UndefOr[Double] = js.undefined, 31 | tabSize: js.UndefOr[Int] = js.undefined 32 | ): ReadlineOptions = { 33 | val _obj$ = js.Dynamic.literal( 34 | ) 35 | input.foreach(_v => _obj$.updateDynamic("input")(_v.asInstanceOf[js.Any])) 36 | output.foreach(_v => _obj$.updateDynamic("output")(_v.asInstanceOf[js.Any])) 37 | completer.foreach(_v => _obj$.updateDynamic("completer")(_v.asInstanceOf[js.Any])) 38 | terminal.foreach(_v => _obj$.updateDynamic("terminal")(_v.asInstanceOf[js.Any])) 39 | historySize.foreach(_v => _obj$.updateDynamic("historySize")(_v.asInstanceOf[js.Any])) 40 | prompt.foreach(_v => _obj$.updateDynamic("prompt")(_v.asInstanceOf[js.Any])) 41 | crlfDelay.foreach(_v => _obj$.updateDynamic("crlfDelay")(_v.asInstanceOf[js.Any])) 42 | removeHistoryDuplicates.foreach(_v => _obj$.updateDynamic("removeHistoryDuplicates")(_v.asInstanceOf[js.Any])) 43 | escapeCodeTimeout.foreach(_v => _obj$.updateDynamic("escapeCodeTimeout")(_v.asInstanceOf[js.Any])) 44 | tabSize.foreach(_v => _obj$.updateDynamic("tabSize")(_v.asInstanceOf[js.Any])) 45 | _obj$.asInstanceOf[ReadlineOptions] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/stream/FinishedOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.stream 2 | 3 | import scala.scalajs.js 4 | 5 | trait FinishedOptions extends js.Object { 6 | var error: js.UndefOr[Boolean] = js.undefined 7 | var readable: js.UndefOr[Boolean] = js.undefined 8 | var writable: js.UndefOr[Boolean] = js.undefined 9 | } 10 | object FinishedOptions { 11 | def apply( 12 | error: js.UndefOr[Boolean] = js.undefined, 13 | readable: js.UndefOr[Boolean] = js.undefined, 14 | writable: js.UndefOr[Boolean] = js.undefined 15 | ): FinishedOptions = { 16 | val _obj$ = js.Dynamic.literal( 17 | ) 18 | error.foreach(_v => _obj$.updateDynamic("error")(_v.asInstanceOf[js.Any])) 19 | readable.foreach(_v => _obj$.updateDynamic("readable")(_v.asInstanceOf[js.Any])) 20 | writable.foreach(_v => _obj$.updateDynamic("writable")(_v.asInstanceOf[js.Any])) 21 | _obj$.asInstanceOf[FinishedOptions] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/stream/LegacyStream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.stream 2 | 3 | import io.scalajs.nodejs.events.IEventEmitter 4 | 5 | import scala.scalajs.js 6 | 7 | @js.native 8 | trait LegacyStream extends IEventEmitter 9 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/ClearImmediate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Stops an immediateObject, as created by setImmediate, from triggering. 6 | * @example 7 | * clearImmediate(immediateObject) 8 | */ 9 | @js.native 10 | trait ClearImmediate extends js.Object { 11 | 12 | /** Stops an immediate, as created by setImmediate, from triggering. 13 | * @param handle 14 | * the immediate handle 15 | * @example 16 | * clearImmediate(immediateObject) 17 | */ 18 | def apply(handle: Immediate): Unit = js.native 19 | } 20 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/ClearInterval.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Stops an intervalObject, as created by setInterval, from triggering. 6 | * @example 7 | * clearInterval(intervalObject) 8 | */ 9 | @js.native 10 | trait ClearInterval extends js.Object { 11 | 12 | /** Stops an interval, as created by setInterval, from triggering. 13 | * @example 14 | * clearInterval(intervalObject) 15 | */ 16 | def apply(handle: Interval): Unit = js.native 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/ClearTimeout.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Prevents a timeoutObject, as created by setTimeout, from triggering. 6 | * @example 7 | * clearTimeout(timeoutObject) 8 | */ 9 | @js.native 10 | trait ClearTimeout extends js.Object { 11 | 12 | /** Prevents a timeout, as created by setTimeout, from triggering. 13 | * @example 14 | * clearTimeout(timeoutObject) 15 | */ 16 | def apply(handle: Timeout): Unit = js.native 17 | } 18 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Immediate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | 7 | /** Immediate Handle 8 | */ 9 | @js.native 10 | trait Immediate extends js.Object { 11 | def _onImmediate: js.Function = js.native 12 | 13 | def hasRef(): Boolean = js.native 14 | 15 | def ref(): Immediate = js.native 16 | 17 | def unref(): Immediate = js.native 18 | } 19 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Interval.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Interval Handle 6 | */ 7 | @js.native 8 | trait Interval extends js.Object { 9 | 10 | /** Indicates whether the interval has been called 11 | * @return 12 | * true, if the interval has already been called 13 | */ 14 | def _called: Boolean = js.native 15 | } 16 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Ref.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** If a timer was previously unref()d, then ref() can be called to explicitly request the timer hold the program open. 6 | * If the timer is already refd calling ref again will have no effect. 7 | */ 8 | @js.native 9 | trait Ref extends js.Object { 10 | 11 | /** If a timer was previously unref()d, then ref() can be called to explicitly request the timer hold the program 12 | * open. If the timer is already refd calling ref again will have no effect. 13 | * 14 | * Returns the timer. 15 | * @example 16 | * ref() 17 | */ 18 | def apply(): Timer = js.native 19 | } 20 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/SetImmediate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Schedules "immediate" execution of callback after I/O events' callbacks and before timers set by setTimeout and 6 | * setInterval are triggered. Returns an immediateObject for possible use with clearImmediate. Additional optional 7 | * arguments may be passed to the callback. 8 | */ 9 | @js.native 10 | trait SetImmediate extends js.Object { 11 | 12 | /** Schedules "immediate" execution of callback after I/O events' callbacks and before timers set by setTimeout and 13 | * setInterval are triggered. Returns an immediateObject for possible use with clearImmediate. Additional optional 14 | * arguments may be passed to the callback. 15 | * 16 | * Callbacks for immediates are queued in the order in which they were created. The entire callback queue is 17 | * processed every event loop iteration. If an immediate is queued from inside an executing callback, that immediate 18 | * won't fire until the next event loop iteration. 19 | * @example 20 | * setImmediate(callback[, arg][, ...]) 21 | */ 22 | def apply(callback: js.Function, args: js.Any*): Immediate = js.native 23 | } 24 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/SetInterval.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Schedules repeated execution of callback every delay milliseconds. Returns a intervalObject for possible use with 6 | * clearInterval. Additional optional arguments may be passed to the callback. 7 | */ 8 | @js.native 9 | trait SetInterval extends js.Object { 10 | 11 | /** Schedules repeated execution of callback every delay milliseconds. Returns a intervalObject for possible use with 12 | * clearInterval. Additional optional arguments may be passed to the callback. 13 | * 14 | * To follow browser behavior, when using delays larger than 2147483647 milliseconds (approximately 25 days) or less 15 | * than 1, Node.js will use 1 as the delay. 16 | * @example 17 | * setInterval(callback, delay[, arg][, ...]) 18 | */ 19 | def apply(callback: js.Function, delay: Int, args: js.Any*): Interval = js.native 20 | } 21 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/SetTimeout.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Schedules execution of a one-time callback after delay milliseconds. Returns a timeoutObject for possible use with 6 | * clearTimeout. Additional optional arguments may be passed to the callback. 7 | */ 8 | @js.native 9 | trait SetTimeout extends js.Object { 10 | 11 | /** Schedules execution of a one-time callback after delay milliseconds. Returns a timeoutObject for possible use with 12 | * clearTimeout. Additional optional arguments may be passed to the callback. 13 | * 14 | * The callback will likely not be invoked in precisely delay milliseconds. Node.js makes no guarantees about the 15 | * exact timing of when callbacks will fire, nor of their ordering. The callback will be called as close as possible 16 | * to the time specified. 17 | * 18 | * To follow browser behavior, when using delays larger than 2147483647 milliseconds (approximately 25 days) or less 19 | * than 1, the timeout is executed immediately, as if the delay was set to 1. 20 | * @example 21 | * setTimeout(callback, delay[, arg][, ...]) 22 | */ 23 | def apply(callback: js.Function, delay: Int, args: js.Any*): Timeout = js.native 24 | } 25 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Timeout.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | 7 | /** Timeout Handle 8 | */ 9 | @js.native 10 | trait Timeout extends js.Object { 11 | 12 | /** Indicates whether the timeout has been called 13 | * @return 14 | * true, if the timeout has already been called 15 | */ 16 | def _called: Boolean = js.native 17 | def hasRef(): Boolean = js.native 18 | 19 | def refresh(): Timeout = js.native 20 | 21 | def ref(): Timeout = js.native 22 | def unref(): Timeout = js.native 23 | } 24 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/Timer.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** Timer 6 | */ 7 | @js.native 8 | trait Timer extends js.Object 9 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/UnRef.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.timers 2 | 3 | import scala.scalajs.js 4 | 5 | /** The opaque value returned by setTimeout and setInterval also has the method timer.unref() which allows the creation 6 | * of a timer that is active but if it is the only item left in the event loop, it won't keep the program running. If 7 | * the timer is already unrefd calling unref again will have no effect. 8 | */ 9 | @js.native 10 | trait UnRef extends js.Object { 11 | 12 | /** The opaque value returned by setTimeout and setInterval also has the method timer.unref() which allows the 13 | * creation of a timer that is active but if it is the only item left in the event loop, it won't keep the program 14 | * running. If the timer is already unrefd calling unref again will have no effect. 15 | * 16 | * In the case of setTimeout, unref creates a separate timer that will wakeup the event loop, creating too many of 17 | * these may adversely effect event loop performance -- use wisely. 18 | * 19 | * Returns the timer. 20 | * @example 21 | * unref() 22 | */ 23 | def unref(): Timer = js.native 24 | } 25 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/timers/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | package object timers { 4 | implicit final class TimeoutEnrichment(private val handle: Timeout) extends AnyVal { 5 | @inline 6 | def clear(): Unit = clearTimeout(handle) 7 | } 8 | 9 | implicit final class IntervalEnrichment(private val handle: Interval) extends AnyVal { 10 | @inline 11 | def clear(): Unit = clearInterval(handle) 12 | } 13 | 14 | implicit final class ImmediateEnrichment(private val immediate: Immediate) extends AnyVal { 15 | @inline 16 | def clear(): Unit = clearImmediate(immediate) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Server.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package tls 3 | 4 | import com.thoughtworks.enableIf 5 | import io.scalajs.nodejs.buffer.Buffer 6 | 7 | import scala.scalajs.js 8 | import scala.scalajs.js.annotation.JSImport 9 | 10 | /** The tls.Server class is a subclass of net.Server that accepts encrypted connections using TLS or SSL. 11 | * @see 12 | * https://nodejs.org/dist/v7.6.0/docs/api/tls.html#tls_class_tls_server 13 | */ 14 | @js.native 15 | @JSImport("tls", "Server") 16 | class Server extends net.Server { 17 | 18 | /** The server.addContext() method adds a secure context that will be used if the client request's SNI hostname 19 | * matches the supplied hostname (or wildcard). 20 | * @param hostname 21 | * A SNI hostname or wildcard (e.g. '*') 22 | * @param context 23 | * An object containing any of the possible properties from the tls.createSecureContext() options 24 | * arguments (e.g. key, cert, ca, etc). 25 | */ 26 | def addContext(hostname: String, context: SecureContextOptions): Unit = js.native 27 | 28 | def setSecureContext(context: SecureContextOptions): Unit = js.native 29 | 30 | /** Returns a Buffer instance holding the keys currently used for encryption/decryption of the TLS Session Tickets 31 | * @return 32 | * a [[Buffer]] 33 | */ 34 | def getTicketKeys(): Buffer = js.native 35 | 36 | /** Updates the keys for encryption/decryption of the TLS Session Tickets. 37 | * @param keys 38 | * The keys used for encryption/decryption of the TLS Session Tickets. 39 | */ 40 | def setTicketKeys(keys: Buffer): Unit = js.native 41 | } 42 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/TLSCertificate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package tls 3 | 4 | import io.scalajs.nodejs.buffer.Buffer 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSName 8 | import scala.scalajs.js.| 9 | 10 | /** TLS Certificate 11 | * @see 12 | * https://nodejs.org/dist/v7.6.0/docs/api/tls.html#tls_tlssocket_getpeercertificate_detailed 13 | */ 14 | @js.native 15 | trait TLSCertificate extends js.Object { 16 | def raw: Buffer = js.native 17 | 18 | def subject: Subject = js.native 19 | def issuer: Subject = js.native 20 | def issuerCertificate: TLSCertificate = js.native 21 | 22 | def valid_from: String = js.native 23 | def valid_to: String = js.native 24 | 25 | def serialNumber: String = js.native 26 | def fingerprint: String = js.native 27 | def fingerprint256: String = js.native 28 | def ext_key_usage: js.Array[String] = js.native 29 | def subjectaltname: String = js.native 30 | def infoAccess: js.Dictionary[js.Array[String]] = js.native 31 | 32 | // For RSA and EC keys 33 | def pubkey: js.UndefOr[Buffer] = js.native 34 | def bits: js.UndefOr[Int] = js.native 35 | 36 | // For RSA keys 37 | def exponent: js.UndefOr[String] = js.native 38 | def modulus: js.UndefOr[String] = js.native 39 | 40 | // For EC keys 41 | def asn1Curve: js.UndefOr[String] = js.native 42 | def nitsCurve: js.UndefOr[String] = js.native 43 | } 44 | 45 | // TODO: Remove js.Array[String] where possible 46 | @js.native 47 | trait Subject extends js.Object { 48 | @JSName("C") var country: js.UndefOr[String | js.Array[String]] = js.native 49 | @JSName("ST") var stateOrProvince: js.UndefOr[String | js.Array[String]] = js.native 50 | @JSName("L") var locality: js.UndefOr[String | js.Array[String]] = js.native 51 | @JSName("O") var organization: js.UndefOr[String | js.Array[String]] = js.native 52 | @JSName("OU") var organizationUnit: js.UndefOr[String | js.Array[String]] = js.native 53 | @JSName("CN") var commonName: js.UndefOr[String | js.Array[String]] = js.native 54 | } 55 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/Tls.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package tls 3 | 4 | import com.thoughtworks.enableIf 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | 9 | /** The tls module provides an implementation of the Transport Layer Security (TLS) and Secure Socket Layer (SSL) 10 | * protocols that is built on top of OpenSSL. 11 | * @see 12 | * https://nodejs.org/dist/v7.6.0/docs/api/tls.html 13 | */ 14 | @js.native 15 | trait Tls extends js.Object { 16 | def checkServerIdentity(hostname: String, cert: TLSCertificate): js.UndefOr[io.scalajs.nodejs.Error] = js.native 17 | 18 | def connect(options: ConnectOptions, callback: js.Function): Unit = js.native 19 | def connect(options: ConnectOptions): Unit = js.native 20 | 21 | def createSecureContext(options: SecureContextOptions): SecureContext = js.native 22 | def createSecureContext(): SecureContext = js.native 23 | 24 | def createServer(options: ServerOptions, secureConnectionListener: js.Function): Server = js.native 25 | def createServer(options: ServerOptions): Server = js.native 26 | def createServer(secureConnectionListener: js.Function): Server = js.native 27 | def createServer(): Server = js.native 28 | 29 | def getCiphers(): js.Array[String] = js.native 30 | 31 | def rootCertificates: js.Array[String] = js.native 32 | 33 | def DEFAULT_ECDH_CURVE: String = js.native 34 | 35 | def DEFAULT_MAX_VERSION: String = js.native 36 | 37 | def DEFAULT_MIN_VERSION: String = js.native 38 | } 39 | 40 | /** TLS Singleton 41 | */ 42 | @js.native 43 | @JSImport("tls", JSImport.Namespace) 44 | object Tls extends Tls 45 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tls/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.buffer.Buffer 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.typedarray.{DataView, TypedArray} 8 | import scala.scalajs.js.| 9 | 10 | package object tls { 11 | type SecureContext = js.Any 12 | 13 | type SecureData = String | js.Array[String] | Buffer | js.Array[Buffer] 14 | 15 | type SecureDataObjectForm = js.Object 16 | 17 | type ALPNProtocols = 18 | Buffer | TypedArray[_, _] | DataView | js.Array[String] | js.Array[TypedArray[_, _]] | js.Array[DataView] 19 | 20 | implicit final class ServerExtensions[T <: Server](private val instance: T) extends AnyVal { 21 | @inline def onKeylog(handler: (Buffer, TLSSocket) => Any): T = instance.on("keylog", handler) 22 | 23 | @inline def onNewSession(handler: (Buffer, Buffer, js.Function0[Unit]) => Any): T = 24 | instance.on("newSession", handler) 25 | @inline def onOCSPRequest(handler: (Buffer, Buffer, js.Function2[Error, js.Any, Unit]) => Any): T = 26 | instance.on("OCSPRequest", handler) 27 | @inline def onResumeSession(handler: (Buffer, js.Function2[Error, Buffer, Unit]) => Any): T = 28 | instance.on("resumeSession", handler) 29 | @inline def onSecureConnection(handler: (tls.TLSSocket => Any)): T = instance.on("secureConnection", handler) 30 | @inline def onTlsClientError(handler: (Error, tls.TLSSocket) => Any): T = instance.on("tlsClientError", handler) 31 | } 32 | 33 | implicit final class TLSSocketExtensions[T <: TLSSocket](private val instance: T) extends AnyVal { 34 | @inline def onKeylog(handler: (Buffer, TLSSocket) => Any): T = instance.on("keylog", handler) 35 | 36 | @inline def onOCSPResponse(handler: (Buffer) => Any): T = instance.on("OCSPResponse", handler) 37 | @inline def onSecureConnect(handler: () => Any): T = instance.on("secureConnect", handler) 38 | @inline def onSession(handler: (Buffer) => Any): T = instance.on("session", handler) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/ReadStream.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.tty 2 | 3 | import io.scalajs.nodejs.FileDescriptor 4 | import io.scalajs.nodejs.net 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | 9 | /** The tty.ReadStream class is a subclass of net.Socket that represents the readable side of a TTY. In normal 10 | * circumstances process.stdin will be the only tty.ReadStream instance in a Node.js process and there should be no 11 | * reason to create additional instances. 12 | * @see 13 | * https://nodejs.org/api/tty.html 14 | */ 15 | @js.native 16 | @JSImport("tty", "ReadStream") 17 | class ReadStream(fd: FileDescriptor) extends net.Socket { 18 | // /////////////////////////////////////////////////////////////////////////////// 19 | // Properties 20 | // /////////////////////////////////////////////////////////////////////////////// 21 | 22 | /** A boolean that is true if the TTY is currently configured to operate as a raw device. Defaults to false. 23 | * @since 0.7.7 24 | */ 25 | def isRaw: Boolean = js.native 26 | 27 | /** Indicates whether the stream is a TTY 28 | */ 29 | def isTTY: Boolean = js.native 30 | 31 | /** Turns on/off raw mode 32 | * @param mode 33 | * mode If true, configures the tty.ReadStream to operate as a raw device. If false, configures the tty.ReadStream 34 | * to operate in its default mode. The readStream.isRaw property will be set to the resulting mode. 35 | * @since 0.7.7 36 | */ 37 | def setRawMode(mode: Boolean): Unit = js.native 38 | } 39 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/TTY.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.tty 2 | 3 | import io.scalajs.nodejs.FileDescriptor 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | /** The tty module provides the tty.ReadStream and tty.WriteStream classes. In most cases, it will not be necessary or 9 | * possible to use this module directly. 10 | * @see 11 | * https://nodejs.org/api/tty.html 12 | */ 13 | @js.native 14 | trait TTY extends js.Object { 15 | // /////////////////////////////////////////////////////////////////////////////// 16 | // Methods 17 | // /////////////////////////////////////////////////////////////////////////////// 18 | 19 | /** The tty.isatty() method returns true if the given fd is associated with a TTY and false if is not. 20 | * @param fd 21 | * A numeric file descriptor 22 | * @since 0.5.8 23 | */ 24 | def isatty(fd: FileDescriptor): Boolean = js.native 25 | } 26 | 27 | /** TTY Singleton 28 | */ 29 | @js.native 30 | @JSImport("tty", JSImport.Namespace) 31 | object TTY extends TTY 32 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/tty/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | /** tty package object 4 | */ 5 | package object tty { 6 | 7 | /** Write Stream Events 8 | * @param stream 9 | * the given [[WriteStream stream]] 10 | */ 11 | implicit final class WriteStreamExtensions[W <: WriteStream](private val stream: W) extends AnyVal { 12 | 13 | /** The 'resize' event is emitted whenever either of the writeStream.columns or writeStream.rows properties have 14 | * changed. No arguments are passed to the listener callback when called. 15 | * @param listener 16 | * the given event handler 17 | * @since 0.7.7 18 | */ 19 | @inline def onResize(listener: () => Any): W = stream.on("resize", listener) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/url/UrlFormatOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.url 2 | 3 | import scala.scalajs.js 4 | 5 | trait UrlFormatOptions extends js.Object { 6 | 7 | /** true if the serialized URL string should include the username and password, false otherwise. Defaults to true. 8 | */ 9 | var auth: js.UndefOr[Boolean] = js.undefined 10 | 11 | /** true if the serialized URL string should include the fragment, false otherwise. Defaults to true. 12 | */ 13 | var fragment: js.UndefOr[Boolean] = js.undefined 14 | 15 | /** true if the serialized URL string should include the search query, false otherwise. Defaults to true. 16 | */ 17 | var search: js.UndefOr[Boolean] = js.undefined 18 | 19 | /** true if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed 20 | * to being Punycode encoded. Defaults to false. 21 | */ 22 | var unicode: js.UndefOr[Boolean] = js.undefined 23 | } 24 | 25 | object UrlFormatOptions { 26 | def apply( 27 | auth: js.UndefOr[Boolean] = js.undefined, 28 | fragment: js.UndefOr[Boolean] = js.undefined, 29 | search: js.UndefOr[Boolean] = js.undefined, 30 | unicode: js.UndefOr[Boolean] = js.undefined 31 | ): UrlFormatOptions = { 32 | val _obj$ = js.Dynamic.literal( 33 | ) 34 | auth.foreach(_v => _obj$.updateDynamic("auth")(_v.asInstanceOf[js.Any])) 35 | fragment.foreach(_v => _obj$.updateDynamic("fragment")(_v.asInstanceOf[js.Any])) 36 | search.foreach(_v => _obj$.updateDynamic("search")(_v.asInstanceOf[js.Any])) 37 | unicode.foreach(_v => _obj$.updateDynamic("unicode")(_v.asInstanceOf[js.Any])) 38 | _obj$.asInstanceOf[UrlFormatOptions] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/TextDecoder.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.util 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSImport 5 | import scala.scalajs.js.typedarray.{ArrayBuffer, ArrayBufferView} 6 | 7 | @js.native 8 | @JSImport("util", "TextDecoder") 9 | class TextDecoder() extends js.Object { 10 | def this(encoding: String) = this() 11 | 12 | val encoding: String = js.native 13 | val fatal: Boolean = js.native 14 | val ignoreBOM: Boolean = js.native 15 | 16 | def decode(buffer: ArrayBuffer, options: TextDecodeOptions): String = js.native 17 | def decode(buffer: ArrayBufferView, options: TextDecodeOptions): String = js.native 18 | def decode(buffer: ArrayBuffer): String = js.native 19 | def decode(buffer: ArrayBufferView): String = js.native 20 | } 21 | 22 | trait TextDecodeOptions extends js.Object { 23 | var stream: js.UndefOr[Boolean] = js.undefined 24 | } 25 | object TextDecodeOptions { 26 | def apply( 27 | stream: js.UndefOr[Boolean] = js.undefined 28 | ): TextDecodeOptions = { 29 | val _obj$ = js.Dynamic.literal( 30 | ) 31 | stream.foreach(_v => _obj$.updateDynamic("stream")(_v.asInstanceOf[js.Any])) 32 | _obj$.asInstanceOf[TextDecodeOptions] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/util/TextEncoder.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.util 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSImport 5 | import scala.scalajs.js.typedarray.Uint8Array 6 | @js.native 7 | @JSImport("util", "TextEncoder") 8 | class TextEncoder() extends js.Object { 9 | def this(encoding: String) = this() 10 | 11 | val encoding: String = js.native 12 | 13 | def encode(text: String): Uint8Array = js.native 14 | } 15 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/Deserializer.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.v8 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, TypedArray} 8 | import scala.scalajs.js.| 9 | 10 | @js.native 11 | @JSImport("v8", "Deserializer") 12 | class Deserializer() extends js.Object { 13 | def readHeader(): Unit = js.native 14 | 15 | def readValue(): Buffer = js.native 16 | 17 | def transferArrayBuffer(id: Int, arrayBuffer: ArrayBuffer): Unit = js.native 18 | 19 | def transferArrayBuffer(id: Int, arrayBuffer: SharedArrayBuffer): Unit = js.native 20 | 21 | def getWireFormatVersion(): Int = js.native 22 | 23 | def readUint32(): Int = js.native 24 | 25 | def readUint64(): js.Tuple2[Int, Int] = js.native 26 | 27 | def readDouble(): Double = js.native 28 | 29 | def readRawBytes(length: Int): Buffer = js.native 30 | 31 | protected def _readHostObject(): TypedArray[_, _] | DataView = js.native 32 | } 33 | 34 | @js.native 35 | @JSImport("v8", "DefaultDeserializer") 36 | class DefaultDeserializer extends Deserializer 37 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/Serializer.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.v8 2 | 3 | import io.scalajs.nodejs.buffer.Buffer 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, TypedArray} 8 | import scala.scalajs.js.| 9 | 10 | @js.native 11 | @JSImport("v8", "Serializer") 12 | class Serializer() extends js.Object { 13 | def writeHeader(): Unit = js.native 14 | 15 | def writeValue(value: js.Any): Unit = js.native 16 | 17 | def releaseBuffer(): Buffer = js.native 18 | 19 | def transferArrayBuffer(id: Int, arrayBuffer: ArrayBuffer): Unit = js.native 20 | 21 | def writeUint32(value: Int): Unit = js.native 22 | 23 | def writeUint32(hi: Int, lo: Int): Unit = js.native 24 | 25 | def writeDouble(value: Double): Unit = js.native 26 | 27 | def writeRawBytes(buffer: TypedArray[_, _]): Unit = js.native 28 | 29 | def writeRawBytes(buffer: DataView): Unit = js.native 30 | 31 | protected def _writeHostObject(obj: TypedArray[_, _] | DataView): Unit = js.native 32 | 33 | protected def _getDataCloneError(message: String): io.scalajs.nodejs.Error = js.native 34 | 35 | protected def _getSharedArrayBufferId(sharedArrayBuffer: SharedArrayBuffer): Int = js.native 36 | } 37 | @js.native 38 | @JSImport("v8", "DefaultSerializer") 39 | class DefaultSerializer extends Serializer 40 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/V8.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.v8 2 | 3 | import com.thoughtworks.enableIf 4 | import io.scalajs.nodejs.buffer.Buffer 5 | 6 | import scala.scalajs.js 7 | import scala.scalajs.js.annotation.JSImport 8 | import scala.scalajs.js.typedarray.{DataView, TypedArray} 9 | 10 | @js.native 11 | trait V8 extends js.Object { 12 | def cachedDataVersionTag(): Int = js.native 13 | 14 | def getHeapSpaceStatistics(): js.Array[HeapSpaceStatistics] = js.native 15 | 16 | def getHeapSnapshot(): io.scalajs.nodejs.stream.Readable = js.native 17 | 18 | def getHeapStatistics(): HeapStatistics = js.native 19 | 20 | def getHeapCodeStatistics(): HeapCodeStatistics = js.native 21 | 22 | def setFlagsFromString(flags: String): Unit = js.native 23 | 24 | def writeHeapSnapshot(filename: String): String = js.native 25 | def writeHeapSnapshot(): String = js.native 26 | 27 | def serialize(value: js.Any): Buffer = js.native 28 | 29 | def deserialize(value: TypedArray[_, _]): Buffer = js.native 30 | def deserialize(value: DataView): Buffer = js.native 31 | } 32 | 33 | @js.native 34 | @JSImport("v8", JSImport.Namespace) 35 | object V8 extends V8 36 | 37 | @js.native 38 | trait HeapSpaceStatistics extends js.Object { 39 | def space_name: String = js.native 40 | def space_size: Double 41 | def space_used_size: Double 42 | def space_available_size: Double 43 | def physical_space_size: Double 44 | } 45 | 46 | @js.native 47 | trait HeapStatistics extends js.Object { 48 | def total_heap_size: Double = js.native 49 | def total_heap_size_executable: Double = js.native 50 | def total_physical_size: Double = js.native 51 | def total_available_size: Double = js.native 52 | def used_heap_size: Double = js.native 53 | def heap_size_limit: Double = js.native 54 | def malloced_memory: Double = js.native 55 | def peak_malloced_memory: Double = js.native 56 | def does_zap_garbage: Double = js.native 57 | def number_of_native_contexts: Double = js.native 58 | def number_of_detached_contexts: Double = js.native 59 | } 60 | 61 | @js.native 62 | trait HeapCodeStatistics extends js.Object { 63 | def code_and_metadata_size: Double = js.native 64 | def bytecode_and_metadata_size: Double = js.native 65 | def external_script_source_size: Double = js.native 66 | } 67 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/v8/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | package object v8 { 6 | // TODO: SharedArrayBuffer is not supported in Scala.js yet 7 | type SharedArrayBuffer = js.Object 8 | } 9 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/vm/SyntheticModule.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.vm 2 | 3 | import scala.scalajs.js 4 | 5 | class SyntheticModule protected () extends js.Object { 6 | def this(exportNames: js.Array[String], evaluateCallback: js.Function, options: SyntheticModuleOptions) = this() 7 | def this(exportNames: js.Array[String], evaluateCallback: js.Function) = this() 8 | 9 | } 10 | 11 | trait SyntheticModuleOptions extends js.Object { 12 | var identifier: js.UndefOr[String] = js.undefined 13 | var context: js.UndefOr[Context] = js.undefined 14 | } 15 | object SyntheticModuleOptions { 16 | def apply( 17 | identifier: js.UndefOr[String] = js.undefined, 18 | context: js.UndefOr[Context] = js.undefined 19 | ): SyntheticModuleOptions = { 20 | val _obj$ = js.Dynamic.literal( 21 | ) 22 | identifier.foreach(_v => _obj$.updateDynamic("identifier")(_v.asInstanceOf[js.Any])) 23 | context.foreach(_v => _obj$.updateDynamic("context")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[SyntheticModuleOptions] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/vm/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | package object vm { 6 | type Context = js.Object 7 | } 8 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/webstream/package.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import scala.scalajs.js 4 | 5 | package object webstream { 6 | // FIXME 7 | type ReadableStream = js.Any 8 | } 9 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/MessageChannel.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSImport 5 | 6 | @js.native 7 | @JSImport("worker_threads", "MessageChannel") 8 | class MessageChannel extends js.Object { 9 | def port1: MessagePort = js.native 10 | def port2: MessagePort = js.native 11 | } 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePort.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import io.scalajs.nodejs.events.IEventEmitter 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | @JSImport("worker_threads", "MessageChannel") 10 | class MessagePort extends IEventEmitter with MessagePoster { 11 | def ref(): Unit = js.native 12 | def start(): Unit = js.native 13 | def unref(): Unit = js.native 14 | } 15 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/MessagePoster.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait MessagePoster extends js.Object { 7 | def postMessage(value: js.Any): Unit = js.native 8 | 9 | def postMessage(value: js.Any, transferList: js.Array[js.|[js.typedarray.ArrayBuffer, MessagePort]]): Unit = js.native 10 | } 11 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/ResourceLimits.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import scala.scalajs.js 4 | 5 | trait ResourceLimits extends js.Object { 6 | var maxYoungGenerationSizeMb: js.UndefOr[Int] = js.undefined 7 | var maxOldGenerationSizeMb: js.UndefOr[Int] = js.undefined 8 | var codeRangeSizeMb: js.UndefOr[Int] = js.undefined 9 | var stackSizeMb: js.UndefOr[Int] = js.undefined 10 | } 11 | object ResourceLimits { 12 | def apply( 13 | maxYoungGenerationSizeMb: js.UndefOr[Int] = js.undefined, 14 | maxOldGenerationSizeMb: js.UndefOr[Int] = js.undefined, 15 | codeRangeSizeMb: js.UndefOr[Int] = js.undefined, 16 | stackSizeMb: js.UndefOr[Int] = js.undefined 17 | ): ResourceLimits = { 18 | val _obj$ = js.Dynamic.literal( 19 | ) 20 | maxYoungGenerationSizeMb.foreach(_v => _obj$.updateDynamic("maxYoungGenerationSizeMb")(_v.asInstanceOf[js.Any])) 21 | maxOldGenerationSizeMb.foreach(_v => _obj$.updateDynamic("maxOldGenerationSizeMb")(_v.asInstanceOf[js.Any])) 22 | codeRangeSizeMb.foreach(_v => _obj$.updateDynamic("codeRangeSizeMb")(_v.asInstanceOf[js.Any])) 23 | stackSizeMb.foreach(_v => _obj$.updateDynamic("stackSizeMb")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[ResourceLimits] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.| 7 | import scala.scalajs.js.annotation.JSImport 8 | 9 | import io.scalajs.nodejs.perf_hooks 10 | 11 | @js.native 12 | @JSImport("worker_threads", "Worker") 13 | class Worker protected () extends js.Object with MessagePoster { 14 | def this(filename: String, workerOptions: WorkerOptions) = this() 15 | def this(filename: String) = this() 16 | 17 | def ref(): Unit = js.native 18 | def unref(): Unit = js.native 19 | 20 | def terminate(): js.Promise[Unit] = js.native 21 | 22 | def threadId: Int = js.native 23 | 24 | def stderr: io.scalajs.nodejs.stream.Readable = js.native 25 | def stdout: io.scalajs.nodejs.stream.Readable = js.native 26 | def stdin: io.scalajs.nodejs.stream.Writable | Null = js.native 27 | 28 | def resourceLimits: ResourceLimits = js.native 29 | 30 | def getHeapSnapshot(): js.Promise[io.scalajs.nodejs.stream.Readable] = js.native 31 | 32 | def performance: PerformanceObject = js.native 33 | 34 | } 35 | 36 | @js.native 37 | trait PerformanceObject extends js.Object { 38 | def eventLoopUtilization(): perf_hooks.EventLoopUtilizationResult = js.native 39 | def eventLoopUtilization(utilization1: perf_hooks.EventLoopUtilizationResult): perf_hooks.EventLoopUtilizationResult = 40 | js.native 41 | def eventLoopUtilization(utilization1: perf_hooks.EventLoopUtilizationResult, 42 | utilization2: perf_hooks.EventLoopUtilizationResult 43 | ): perf_hooks.EventLoopUtilizationResult = js.native 44 | } 45 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | 7 | trait WorkerOptions extends js.Object { 8 | var env: js.UndefOr[js.Object] = js.undefined 9 | var eval: js.UndefOr[Boolean] = js.undefined 10 | var execArgv: js.UndefOr[js.Array[String]] = js.undefined 11 | var stdin: js.UndefOr[Boolean] = js.undefined 12 | var stdout: js.UndefOr[Boolean] = js.undefined 13 | var stderr: js.UndefOr[Boolean] = js.undefined 14 | var workerData: js.UndefOr[js.Any] = js.undefined 15 | 16 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 17 | var trackUnmanagedFds: js.UndefOr[Boolean] = js.undefined 18 | @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) 19 | var transferList: js.UndefOr[js.Array[js.Object]] = js.undefined 20 | 21 | var resourceLimits: js.UndefOr[ResourceLimits] = js.undefined 22 | } 23 | 24 | object WorkerOptions { 25 | def apply( 26 | env: js.UndefOr[js.Object] = js.undefined, 27 | eval: js.UndefOr[Boolean] = js.undefined, 28 | execArgv: js.UndefOr[js.Array[String]] = js.undefined, 29 | stdin: js.UndefOr[Boolean] = js.undefined, 30 | stdout: js.UndefOr[Boolean] = js.undefined, 31 | stderr: js.UndefOr[Boolean] = js.undefined, 32 | workerData: js.UndefOr[js.Any] = js.undefined, 33 | trackUnmanagedFds: js.UndefOr[Boolean] = js.undefined, 34 | transferList: js.UndefOr[js.Array[js.Object]] = js.undefined, 35 | resourceLimits: js.UndefOr[ResourceLimits] = js.undefined 36 | ): WorkerOptions = { 37 | val _obj$ = js.Dynamic.literal( 38 | ) 39 | env.foreach(_v => _obj$.updateDynamic("env")(_v.asInstanceOf[js.Any])) 40 | eval.foreach(_v => _obj$.updateDynamic("eval")(_v.asInstanceOf[js.Any])) 41 | execArgv.foreach(_v => _obj$.updateDynamic("execArgv")(_v.asInstanceOf[js.Any])) 42 | stdin.foreach(_v => _obj$.updateDynamic("stdin")(_v.asInstanceOf[js.Any])) 43 | stdout.foreach(_v => _obj$.updateDynamic("stdout")(_v.asInstanceOf[js.Any])) 44 | stderr.foreach(_v => _obj$.updateDynamic("stderr")(_v.asInstanceOf[js.Any])) 45 | workerData.foreach(_v => _obj$.updateDynamic("workerData")(_v.asInstanceOf[js.Any])) 46 | trackUnmanagedFds.foreach(_v => _obj$.updateDynamic("trackUnmanagedFds")(_v.asInstanceOf[js.Any])) 47 | transferList.foreach(_v => _obj$.updateDynamic("transferList")(_v.asInstanceOf[js.Any])) 48 | resourceLimits.foreach(_v => _obj$.updateDynamic("resourceLimits")(_v.asInstanceOf[js.Any])) 49 | _obj$.asInstanceOf[WorkerOptions] 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/worker_threads/WorkerThreads.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.worker_threads 2 | 3 | import com.thoughtworks.enableIf 4 | 5 | import scala.scalajs.js 6 | import scala.scalajs.js.annotation.JSImport 7 | 8 | @js.native 9 | trait WorkerThreads extends js.Object { 10 | def isMainThread: Boolean = js.native 11 | 12 | def parentPort: js.|[MessagePort, Null] = js.native 13 | 14 | def SHARE_ENV: js.Symbol = js.native 15 | 16 | def threadId: Int = js.native 17 | 18 | def workerData: js.Any = js.native 19 | 20 | def moveMessagePortToContext(port: MessagePort, contextifiedSandbox: io.scalajs.nodejs.vm.Context): MessagePort = 21 | js.native 22 | 23 | def receiveMessageOnPort(port: MessagePort): js.UndefOr[js.Object] = js.native 24 | 25 | def resourceLimits: ResourceLimits = js.native 26 | } 27 | 28 | @js.native 29 | @JSImport("worker_threads", JSImport.Namespace) 30 | object WorkerThreads extends WorkerThreads 31 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/BrotliCompress.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.zlib 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSImport 5 | 6 | /** Available in Node.js v12 and later 7 | */ 8 | @js.native 9 | @JSImport("zlib", "BrotliCompress") 10 | class BrotliCompress extends ZlibBase 11 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/BrotliDecompress.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.zlib 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.annotation.JSImport 5 | 6 | /** Available in Node.js v12 and later 7 | */ 8 | @js.native 9 | @JSImport("zlib", "BrotliDecompress") 10 | class BrotliDecompress extends ZlibBase 11 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/BrotliOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.zlib 2 | 3 | import scala.scalajs.js 4 | 5 | trait BrotliOptions extends js.Object { 6 | var flush: js.UndefOr[Int] = js.undefined 7 | var finishFlush: js.UndefOr[Int] = js.undefined 8 | var chunkSize: js.UndefOr[Int] = js.undefined 9 | var params: js.UndefOr[js.Dictionary[js.Any]] = js.undefined 10 | } 11 | object BrotliOptions { 12 | def apply( 13 | flush: js.UndefOr[Int] = js.undefined, 14 | finishFlush: js.UndefOr[Int] = js.undefined, 15 | chunkSize: js.UndefOr[Int] = js.undefined, 16 | params: js.UndefOr[js.Any] = js.undefined 17 | ): BrotliOptions = { 18 | val _obj$ = js.Dynamic.literal( 19 | ) 20 | flush.foreach(_v => _obj$.updateDynamic("flush")(_v.asInstanceOf[js.Any])) 21 | finishFlush.foreach(_v => _obj$.updateDynamic("finishFlush")(_v.asInstanceOf[js.Any])) 22 | chunkSize.foreach(_v => _obj$.updateDynamic("chunkSize")(_v.asInstanceOf[js.Any])) 23 | params.foreach(_v => _obj$.updateDynamic("params")(_v.asInstanceOf[js.Any])) 24 | _obj$.asInstanceOf[BrotliOptions] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/CompressionOptions.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.zlib 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, TypedArray} 5 | import scala.scalajs.js.| 6 | 7 | trait CompressionOptions extends js.Object { 8 | var flush: js.UndefOr[CompressionFlush] = js.undefined 9 | 10 | var finishFlush: js.UndefOr[CompressionFlush] = js.undefined 11 | 12 | var chunkSize: js.UndefOr[Int] = js.undefined 13 | 14 | var windowBits: js.UndefOr[Int] = js.undefined 15 | 16 | /** (compression only) 17 | */ 18 | var level: js.UndefOr[CompressionLevel] = js.undefined 19 | 20 | /** (compression only) 21 | */ 22 | var memLevel: js.UndefOr[CompressionLevel] = js.undefined 23 | 24 | /** (compression only) 25 | */ 26 | var strategy: js.UndefOr[CompressionStrategy] = js.undefined 27 | 28 | /** deflate/inflate only, empty dictionary by default 29 | */ 30 | var dictionary: js.UndefOr[TypedArray[_, _] | DataView | ArrayBuffer] = js.undefined 31 | 32 | var info: js.UndefOr[Boolean] = js.undefined 33 | } 34 | 35 | object CompressionOptions { 36 | def apply( 37 | flush: js.UndefOr[CompressionFlush] = js.undefined, 38 | finishFlush: js.UndefOr[CompressionFlush] = js.undefined, 39 | chunkSize: js.UndefOr[Int] = js.undefined, 40 | windowBits: js.UndefOr[Int] = js.undefined, 41 | level: js.UndefOr[CompressionLevel] = js.undefined, 42 | memLevel: js.UndefOr[CompressionLevel] = js.undefined, 43 | strategy: js.UndefOr[CompressionStrategy] = js.undefined, 44 | dictionary: js.UndefOr[TypedArray[_, _] | DataView | ArrayBuffer] = js.undefined, 45 | info: js.UndefOr[Boolean] = js.undefined 46 | ): CompressionOptions = { 47 | val _obj$ = js.Dynamic.literal( 48 | ) 49 | flush.foreach(_v => _obj$.updateDynamic("flush")(_v.asInstanceOf[js.Any])) 50 | finishFlush.foreach(_v => _obj$.updateDynamic("finishFlush")(_v.asInstanceOf[js.Any])) 51 | chunkSize.foreach(_v => _obj$.updateDynamic("chunkSize")(_v.asInstanceOf[js.Any])) 52 | windowBits.foreach(_v => _obj$.updateDynamic("windowBits")(_v.asInstanceOf[js.Any])) 53 | level.foreach(_v => _obj$.updateDynamic("level")(_v.asInstanceOf[js.Any])) 54 | memLevel.foreach(_v => _obj$.updateDynamic("memLevel")(_v.asInstanceOf[js.Any])) 55 | strategy.foreach(_v => _obj$.updateDynamic("strategy")(_v.asInstanceOf[js.Any])) 56 | dictionary.foreach(_v => _obj$.updateDynamic("dictionary")(_v.asInstanceOf[js.Any])) 57 | info.foreach(_v => _obj$.updateDynamic("info")(_v.asInstanceOf[js.Any])) 58 | _obj$.asInstanceOf[CompressionOptions] 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Deflate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Compress data using deflate. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "Deflate") 11 | class Deflate extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/DeflateRaw.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Compress data using deflate, and do not append a zlib header. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "DeflateRaw") 11 | class DeflateRaw extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Gunzip.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Decompress a gzip stream. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "Gunzip") 11 | class Gunzip extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Gzip.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Compress data using gzip. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "Gzip") 11 | class Gzip extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Inflate.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Decompress a deflate stream. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "Inflate") 11 | class Inflate extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/InflateRaw.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Decompress a raw deflate stream. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "InflateRaw") 11 | class InflateRaw extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/Unzip.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | package zlib 3 | 4 | import scala.scalajs.js 5 | import scala.scalajs.js.annotation.JSImport 6 | 7 | /** Decompress a raw deflate stream. 8 | */ 9 | @js.native 10 | @JSImport("zlib", "Unzip") 11 | class Unzip extends ZlibBase 12 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/main/scala/io/scalajs/nodejs/zlib/ZlibBase.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.zlib 2 | 3 | import io.scalajs.nodejs.stream 4 | 5 | import scala.scalajs.js 6 | 7 | /** Not exported by the zlib module. It is documented here because it is the base class of the compressor/decompressor 8 | * classes. 9 | * 10 | * This class inherits from stream.Transform, allowing zlib objects to be used in pipes and similar stream operations. 11 | */ 12 | @js.native 13 | trait ZlibBase extends stream.Transform { 14 | def bytesWritten: Double = js.native 15 | 16 | def close(callback: js.Function): Unit = js.native 17 | def close(): Unit = js.native 18 | 19 | def flush(kind: CompressionFlush, callback: js.Function): Unit = js.native 20 | def flush(callback: js.Function): Unit = js.native 21 | 22 | def params(level: CompressionLevel, strategy: CompressionStrategy, callback: js.Function): Unit = js.native 23 | 24 | def reset(): Unit = js.native 25 | } 26 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/test/scala/io/scalajs/nodejs/AbortControllerTest.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs 2 | 3 | import org.scalatest.funsuite.AnyFunSuite 4 | 5 | class AbortControllerTest extends AnyFunSuite { 6 | test("AbortController") { 7 | val ac = new AbortController() 8 | assert(ac.signal != null) 9 | } 10 | 11 | test("AbortSignal") { 12 | val as = AbortSignal.abort() 13 | assert(as.aborted) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/test/scala/io/scalajs/nodejs/crypto/CryptoNodeJS14Test.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.crypto 2 | 3 | import org.scalatest.funsuite.AnyFunSuite 4 | 5 | class CryptoNodeJS14Test extends AnyFunSuite { 6 | test("randomInt") { 7 | val i1 = Crypto.randomInt(10) 8 | assert(0 <= i1 && i1 <= 10) 9 | 10 | val i2 = Crypto.randomInt(10, 100) 11 | assert(10 <= i2 && i2 <= 100) 12 | 13 | Crypto.randomInt( 14 | 10, 15 | (_, i3) => { 16 | assert(0 <= i3 && i3 <= 10) 17 | } 18 | ) 19 | 20 | Crypto.randomInt( 21 | 10, 22 | 100, 23 | (_, i4) => { 24 | assert(10 <= i4 && i4 <= 100) 25 | } 26 | ) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/nodejs-v16/src/test/scala/io/scalajs/nodejs/os/NodeJS14Test.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.os 2 | 3 | import org.scalatest.funsuite.AnyFunSuite 4 | 5 | class NodeJS14Test extends AnyFunSuite { 6 | test("version") { 7 | assert(OS.version().isInstanceOf[String]) 8 | assert(OS.version().nonEmpty) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/scala/io/scalajs/nodejs/internal/CompilerSwitches.scala: -------------------------------------------------------------------------------- 1 | package io.scalajs.nodejs.internal 2 | 3 | import scala.reflect.macros.whitebox 4 | 5 | object CompilerSwitches { 6 | private val nodejsVersionPattern = "^nodeJs([0-9]{1,2})\\.([0-9]{1,2})\\.([0-9]{1,2})$".r 7 | 8 | private def compare(predicate: (Int, Int, Int) => Boolean): String => Boolean = { version: String => 9 | val nodejsVersionPattern(major, minor, patch) = version 10 | predicate(major.toInt, minor.toInt, patch.toInt) 11 | } 12 | 13 | final val isNodeJs14 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 14)) 14 | final val gteNodeJs14 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 14)) 15 | final val ltNodeJs14 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major < 14)) 16 | 17 | final val isNodeJs16 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major == 16)) 18 | final val gteNodeJs16 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major >= 16)) 19 | final val ltNodeJs16 = (c: whitebox.Context) => c.settings.exists(compare((major, _, _) => major < 16)) 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-sfs", 3 | "version": "0.4.2", 4 | "private": true, 5 | "scripts": { 6 | "lint-md": "remark .", 7 | "fix-md": "remark . -o" 8 | }, 9 | "remarkConfig": { 10 | "plugins": [ 11 | "remark-preset-lint-recommended" 12 | ] 13 | }, 14 | "dependencies": { 15 | "remark-cli": "^9.0.0", 16 | "remark-preset-lint-recommended": "^5.0.0", 17 | "source-map-support": "^0.5.19" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /project/Dependencies.scala: -------------------------------------------------------------------------------- 1 | import sbt._ 2 | import sbt.Keys._ 3 | import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ 4 | 5 | object Dependencies { 6 | val scalaReflect = Def.setting("org.scala-lang" % "scala-reflect" % scalaVersion.value) 7 | val scalatestVersion = "3.2.19" 8 | 9 | val core = Def.setting( 10 | Seq( 11 | scalaReflect.value, 12 | "org.scalatest" %%% "scalatest" % scalatestVersion % "test" 13 | ) 14 | ) 15 | 16 | val app = Def.setting( 17 | Seq( 18 | scalaReflect.value, 19 | "net.exoego" %%% "scalajs-types-util" % "0.3.0" % "provided", 20 | "org.scalatest" %%% "scalatest" % scalatestVersion % "test", 21 | "com.thoughtworks.enableIf" %% "enableif" % "1.2.0" 22 | ) 23 | ) 24 | 25 | } 26 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.1 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1") 2 | addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") 3 | addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0") 4 | addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.1.0") 5 | addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") 6 | -------------------------------------------------------------------------------- /script/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE_DIR=$(pwd)/app/nodejs-v16/src/main 4 | 5 | V14_DIR=$(pwd)/app/nodejs-v14/src/main 6 | if [ -e "$V14_DIR" ]; then 7 | unlink "$V14_DIR" 8 | echo "V14 dir already exists." 9 | else 10 | ln -s "$SOURCE_DIR" "$V14_DIR"; 11 | echo "V14 dir created."; 12 | fi 13 | 14 | V12_DIR=$(pwd)/app/nodejs-v12/src/main 15 | if [ -e "$V12_DIR" ]; then 16 | unlink "$V12_DIR" 17 | echo "V12 dir already exists." 18 | else 19 | ln -s "$SOURCE_DIR" "$V12_DIR"; 20 | echo "V12 dir created."; 21 | fi 22 | --------------------------------------------------------------------------------