Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

44 changes: 44 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import js from "@eslint/js"
import globals from "globals"
import tseslint from "typescript-eslint"
import pluginN from "eslint-plugin-n"
import promise from "eslint-plugin-promise"

export default [
{
ignores: [
"node_modules/",
"dist/",
"*.d.ts",
"test/**/*.bundle.js"
]
},
js.configs.recommended,
...tseslint.configs.recommended,
{
plugins: {
n: pluginN,
promise
},
languageOptions: {
ecmaVersion: 2020,
sourceType: "module",
globals: {
...globals.node
}
},
rules: {
curly: ["error", "all"],
"brace-style": ["error", "1tbs", { allowSingleLine: false }],
"guard-for-in": "error",
"no-console": "error",
"no-debugger": "error",
radix: "error",
"n/no-deprecated-api": "warn",
"n/no-process-exit": "off",
"no-process-exit": "off",
"n/shebang": "off",
"no-empty-function": "error"
},
}
]
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@
"homepage": "https://github.com/TechTeamer/janus-api#readme",
"dependencies": {
"improved-yarn-audit": "^3.0.4",
"isomorphic-ws": "^4.0.1",
"isomorphic-ws": "^5.0.0",
"sdp": "^3.0.1",
"uuid": "^8.2.0",
"ws": "^8.2.0"
},
"devDependencies": {
"@types/node": "^20.12.12",
"@eslint/js": "^10.0.1",
"@types/node": "^25.9.1",
"esbuild": "^0.28.0",
"eslint": "^8.8.0",
"eslint": "^10.4.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-n": "^15.2.4",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-n": "^18.0.1",
"eslint-plugin-promise": "^7.3.0",
"eslint-plugin-standard": "^5.0.0",
"http-server": "^14.1.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.10.0",
"webrtc-adapter": "^8.1.1"
"typescript": "^6.0.3",
"typescript-eslint": "^8.59.4",
"webrtc-adapter": "^9.0.5"
}
}
8 changes: 4 additions & 4 deletions src/Janus.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import WebSocket from 'isomorphic-ws'
import JanusPlugin from './JanusPlugin.js'
import { v4 as uuid } from 'uuid'

const ignoredErrorCodes = [
458, // JANUS_ERROR_SESSION_NOT_FOUND
Expand Down Expand Up @@ -47,7 +46,7 @@ class Janus {
return resolve(this)
}

const transaction = uuid()
const transaction = crypto.randomUUID()
const request = { janus: 'create', transaction }

this.transactions[transaction] = {
Expand Down Expand Up @@ -111,7 +110,7 @@ class Janus {
if (!replyType) {
replyType = 'ack'
}
const transactionId = uuid()
const transactionId = crypto.randomUUID()

return new Promise((resolve, reject) => {
if (timeoutMs) {
Expand Down Expand Up @@ -146,7 +145,7 @@ class Janus {
const request = Object.assign({}, payload, {
janus: type,
session_id: this.sessionId,
transaction: uuid()
transaction: crypto.randomUUID()
})

this.logger.debug('Janus sending', request)
Expand Down Expand Up @@ -221,6 +220,7 @@ class Janus {
let json
try {
json = JSON.parse(messageEvent.data)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
this.logger.error('cannot parse message', messageEvent.data)
return
Expand Down
6 changes: 3 additions & 3 deletions src/JanusPlugin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { v4 as uuid } from 'uuid'
import EventEmitter from 'events'
import EventEmitter from 'node:events'

class JanusPlugin extends EventEmitter {
constructor (logger) {
super()
this.id = uuid()
this.id = crypto.randomUUID()
/** @var Janus */
this.janus = undefined
this.janusHandleId = undefined
Expand Down Expand Up @@ -33,6 +32,7 @@ class JanusPlugin extends EventEmitter {
return this
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
error (cause) {
// Couldn't attach to the plugin
}
Expand Down
1 change: 1 addition & 0 deletions src/plugin/VideoRoomPublisherJanusPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class VideoRoomPublisherJanusPlugin extends JanusPlugin {
body.audio_port = audioPortNumber
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
return this.transaction('message', { body }, 'success').then(({ data, json }) => {
if (data && data.rtp_stream && data.rtp_stream.video_stream_id) {
this.rtpForwardVideoStreamId = data.rtp_stream.video_stream_id
Expand Down
53 changes: 33 additions & 20 deletions test/buildtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,41 @@

import esbuild from 'esbuild'
import * as httpServer from 'http-server'
const pack = (input, output) => {
esbuild.build({

const pack = async (input, output) => {
await esbuild.build({
entryPoints: [input],
bundle: true,
outfile: output
}).catch(err => {
console.log(err)
outfile: output,
platform: 'node',
target: 'node20'
})

console.log(`Built: ${output}`)
}

const main = async () => {
await Promise.all([
pack('./test/echo/echo.js', './test/echo/echo.bundle.js'),
pack('./test/recordplay/recordplay.js', './test/recordplay/recordplay.bundle.js'),
pack('./test/videoroom/publisher.js', './test/videoroom/publisher.bundle.js'),
pack('./test/videoroom/listener.js', './test/videoroom/listener.bundle.js'),
pack('./test/streaming/streaming.js', './test/streaming/streaming.bundle.js'),
pack('./test/videocall/videocall.js', './test/videocall/videocall.bundle.js')
])

console.log('All builds finished')

httpServer.createServer({
showDir: true,
root: './test/',
https: {
key: '/workspace/cert/dev.key',
cert: '/workspace/cert/dev.crt'
}
}).listen(8080)

console.log('Server running at https://localhost:8080')
}

pack('./test/echo/echo.js', './test/echo/echo.bundle.js')
pack('./test/recordplay/recordplay.js', './test/recordplay/recordplay.bundle.js')
pack('./test/videoroom/publisher.js', './test/videoroom/publisher.bundle.js')
pack('./test/videoroom/listener.js', './test/videoroom/listener.bundle.js')
pack('./test/streaming/streaming.js', './test/streaming/streaming.bundle.js')
pack('./test/videocall/videocall.js', './test/videocall/videocall.bundle.js')

httpServer.createServer({
showDir: true,
root: './test/',
https: {
key: '/workspace/cert/dev.key',
cert: '/workspace/cert/dev.crt'
}
}).listen(8080)
main().catch(console.error)
2 changes: 1 addition & 1 deletion test/echo/echo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, no-undef, no-unused-vars */
/* eslint-disable no-console, no-undef */

import 'webrtc-adapter'
import common from '../common.js'
Expand Down
2 changes: 1 addition & 1 deletion test/recordplay/recordplay.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, no-undef, no-unused-vars */
/* eslint-disable no-console, no-undef */

import 'webrtc-adapter'
import common from '../common.js'
Expand Down
3 changes: 2 additions & 1 deletion test/streaming/streaming.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, no-undef, no-unused-vars */
/* eslint-disable no-console, no-undef */

import 'webrtc-adapter'
import { JanusConfig } from '../../src/Config.js'
Expand Down Expand Up @@ -63,6 +63,7 @@ janus.connect().then(() => {

listButton.removeAttribute('disabled')
listButton.addEventListener('click', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
streaming.list().then(({ data, json }) => {
console.log('LIST', data)
createStreamTable(data.list)
Expand Down
2 changes: 1 addition & 1 deletion test/videocall/videocall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, no-undef, no-unused-vars */
/* eslint-disable no-console, no-undef */

import { JanusConfig } from '../../src/Config.js'
import common from '../common.js'
Expand Down
2 changes: 1 addition & 1 deletion test/videoroom/listener.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, no-undef, no-unused-vars */
/* eslint-disable no-console, no-undef */

import 'webrtc-adapter'
import { JanusConfig } from '../../src/Config.js'
Expand Down
2 changes: 1 addition & 1 deletion test/videoroom/publisher.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, no-undef, no-unused-vars */
/* eslint-disable no-console, no-undef */
import 'webrtc-adapter'
import { JanusConfig, JanusRoomConfig } from '../../src/Config.js'
import common from '../common.js'
Expand Down
6 changes: 4 additions & 2 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"paths": {
"*": ["./src/*"]
},
"declaration": true,
"esModuleInterop": true,
"inlineSourceMap": false,
"lib": ["esnext"],
"listEmittedFiles": false,
"listFiles": false,
"moduleResolution": "node",
"moduleResolution": "bundler",
"noFallthroughCasesInSwitch": true,
"pretty": true,
"resolveJsonModule": true,
Expand Down
Loading
Loading