Skip to content

Commit

Permalink
build: always use ESM and don't mix with CJS
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Aug 17, 2023
1 parent 3684fd5 commit 9c5f4e4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 44 deletions.
5 changes: 1 addition & 4 deletions src/utils/media/effects/virtual-background/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @flow
import * as wasmCheck from 'wasm-check'

import JitsiStreamBackgroundEffect from './JitsiStreamBackgroundEffect.js'
import createTFLiteSIMDModule from './vendor/tflite/tflite-simd.js'
Expand Down Expand Up @@ -29,14 +29,11 @@ export async function createVirtualBackgroundEffect(virtualBackground, dispatch)
throw new Error('JitsiStreamBackgroundEffect not supported!')
}
let tflite
let wasmCheck

// Checks if WebAssembly feature is supported or enabled by/in the browser.
// Conditional import of wasm-check package is done to prevent
// the browser from crashing when the user opens the app.

try {
wasmCheck = require('wasm-check')
if (wasmCheck?.feature?.simd) {
tflite = await createTFLiteSIMDModule()
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/media/pipeline/VirtualBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*
*/

import * as wasmCheck from 'wasm-check'

import { VIRTUAL_BACKGROUND } from '../../../constants.js'
import JitsiStreamBackgroundEffect from '../effects/virtual-background/JitsiStreamBackgroundEffect.js'
import TrackSinkSource from './TrackSinkSource.js'
Expand Down Expand Up @@ -72,8 +74,6 @@ export default class VirtualBackground extends TrackSinkSource {
}

static _checkWasmSupport() {
const wasmCheck = require('wasm-check')

if (!wasmCheck.support()) {
this._wasmSupported = false

Expand Down
10 changes: 8 additions & 2 deletions src/utils/webrtc/simplewebrtc/getscreenmedia.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global module, chrome */
/* global chrome */

// getScreenMedia helper by @HenrikJoreteg
const getUserMedia = function(constraints, callback) {
Expand All @@ -23,7 +23,13 @@ const getUserMedia = function(constraints, callback) {
// cache for constraints and callback
const cache = {}

module.exports = function(mode, constraints, cb) {
/**
*
* @param mode

Check warning on line 28 in src/utils/webrtc/simplewebrtc/getscreenmedia.js

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "mode" description

Check warning on line 28 in src/utils/webrtc/simplewebrtc/getscreenmedia.js

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "mode" type
* @param constraints

Check warning on line 29 in src/utils/webrtc/simplewebrtc/getscreenmedia.js

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "constraints" description

Check warning on line 29 in src/utils/webrtc/simplewebrtc/getscreenmedia.js

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "constraints" type
* @param cb

Check warning on line 30 in src/utils/webrtc/simplewebrtc/getscreenmedia.js

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "cb" description

Check warning on line 30 in src/utils/webrtc/simplewebrtc/getscreenmedia.js

View workflow job for this annotation

GitHub Actions / eslint

Missing JSDoc @param "cb" type
*/
export default function(mode, constraints, cb) {
const hasConstraints = arguments.length === 3
const callback = hasConstraints ? cb : constraints
let error
Expand Down
30 changes: 13 additions & 17 deletions src/utils/webrtc/simplewebrtc/localmedia.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
/* global module */
import util from 'util'

const util = require('util')

const mockconsole = require('mockconsole')
const WildEmitter = require('wildemitter')
import mockconsole from 'mockconsole'
import WildEmitter from 'wildemitter'

// Only mediaDevicesManager is used, but it can not be assigned here due to not
// being initialized yet.
const BlackVideoEnforcer = require('../../media/pipeline/BlackVideoEnforcer.js').default
const MediaDevicesSource = require('../../media/pipeline/MediaDevicesSource.js').default
const SpeakingMonitor = require('../../media/pipeline/SpeakingMonitor.js').default
const TrackConstrainer = require('../../media/pipeline/TrackConstrainer.js').default
const TrackEnabler = require('../../media/pipeline/TrackEnabler.js').default
const TrackToStream = require('../../media/pipeline/TrackToStream.js').default
const VirtualBackground = require('../../media/pipeline/VirtualBackground.js').default
const webrtcIndex = require('../index.js')
const getScreenMedia = require('./getscreenmedia.js')
import BlackVideoEnforcer from '../../media/pipeline/BlackVideoEnforcer.js'
import MediaDevicesSource from '../../media/pipeline/MediaDevicesSource.js'
import SpeakingMonitor from '../../media/pipeline/SpeakingMonitor.js'
import TrackConstrainer from '../../media/pipeline/TrackConstrainer.js'
import TrackEnabler from '../../media/pipeline/TrackEnabler.js'
import TrackToStream from '../../media/pipeline/TrackToStream.js'
import VirtualBackground from '../../media/pipeline/VirtualBackground.js'
import * as webrtcIndex from '../index.js'
import getScreenMedia from './getscreenmedia.js'

/**
* @param {object} opts the options object.
*/
function LocalMedia(opts) {
export default function LocalMedia(opts) {
WildEmitter.call(this)

const config = this.config = {
Expand Down Expand Up @@ -511,5 +509,3 @@ Object.defineProperty(LocalMedia.prototype, 'localScreen', {
return this.localScreens.length > 0 ? this.localScreens[0] : null
},
})

module.exports = LocalMedia
14 changes: 5 additions & 9 deletions src/utils/webrtc/simplewebrtc/simplewebrtc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/* global module */
import mockconsole from 'mockconsole'
import webrtcSupport from 'webrtcsupport'
import WildEmitter from 'wildemitter'

const mockconsole = require('mockconsole')
const webrtcSupport = require('webrtcsupport')
const WildEmitter = require('wildemitter')

const WebRTC = require('./webrtc.js')
import WebRTC from './webrtc.js'

/**
* @param {object} opts the options object.
*/
function SimpleWebRTC(opts) {
export default function SimpleWebRTC(opts) {
const self = this
const options = opts || {}
const config = this.config = {
Expand Down Expand Up @@ -294,5 +292,3 @@ SimpleWebRTC.prototype.stopScreenShare = function() {
}
})
}

module.exports = SimpleWebRTC
16 changes: 6 additions & 10 deletions src/utils/webrtc/simplewebrtc/webrtc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/* global module */
import util from 'util'

const util = require('util')
import mockconsole from 'mockconsole'
import webrtcSupport from 'webrtcsupport'

const mockconsole = require('mockconsole')
const webrtcSupport = require('webrtcsupport')

const localMedia = require('./localmedia.js')
const Peer = require('./peer.js')
import localMedia from './localmedia.js'
import Peer from './peer.js'

/**
* @param {object} opts the options object.
*/
function WebRTC(opts) {
export default function WebRTC(opts) {
const self = this
const options = opts || {}
this.config = {
Expand Down Expand Up @@ -132,5 +130,3 @@ WebRTC.prototype.sendDirectlyToAll = function(channel, message, payload) {
}
})
}

module.exports = WebRTC

0 comments on commit 9c5f4e4

Please sign in to comment.