From 4d329b510f0ef2c6d154a1edcf396ab314182561 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Wed, 14 Jun 2017 13:13:41 -0500 Subject: [PATCH] ref: module.exports -> export for the ES6 modules --- .jshintignore | 1 + app.js | 93 +++++++++----------- modules/API/external/external_api.js | 4 +- modules/API/external/index.js | 3 + modules/UI/UI.js | 14 +-- modules/UI/UIErrors.js | 14 +-- modules/UI/util/JitsiPopover.js | 4 +- modules/UI/util/MessageHandler.js | 2 +- modules/keyboardshortcut/keyboardshortcut.js | 4 +- webpack.config.js | 2 +- 10 files changed, 66 insertions(+), 75 deletions(-) create mode 100644 modules/API/external/index.js diff --git a/.jshintignore b/.jshintignore index 92a5192db..bdb025c72 100644 --- a/.jshintignore +++ b/.jshintignore @@ -16,6 +16,7 @@ react/ # The following are checked by ESLint with the minimum configuration which does # not supersede JSHint but take advantage of advanced language features such as # Facebook Flow which are not supported by JSHint. +app.js modules/translation/translation.js analytics.js diff --git a/app.js b/app.js index 5bd759360..470420d0d 100644 --- a/app.js +++ b/app.js @@ -15,60 +15,51 @@ import 'aui-experimental-css'; window.toastr = require("toastr"); -import conference from './conference'; -import API from './modules/API'; -import keyboardshortcut from './modules/keyboardshortcut/keyboardshortcut'; -import remoteControl from "./modules/remotecontrol/RemoteControl"; -import settings from "./modules/settings/Settings"; -import translation from "./modules/translation/translation"; -import UI from "./modules/UI/UI"; +export conference from './conference'; +export API from './modules/API'; +export keyboardshortcut from './modules/keyboardshortcut/keyboardshortcut'; +export remoteControl from "./modules/remotecontrol/RemoteControl"; +export settings from "./modules/settings/Settings"; +export translation from "./modules/translation/translation"; +export UI from "./modules/UI/UI"; -const APP = { - API, - conference, +/** + * After the APP has been initialized provides utility methods for dealing + * with the conference room URL(address). + * @type ConferenceUrl + */ +export let ConferenceUrl = null; - /** - * After the APP has been initialized provides utility methods for dealing - * with the conference room URL(address). - * @type ConferenceUrl - */ - ConferenceUrl: null, - - // Used by do_external_connect.js if we receive the attach data after - // connect was already executed. status property can be "initialized", - // "ready" or "connecting". We are interested in "ready" status only which - // means that connect was executed but we have to wait for the attach data. - // In status "ready" handler property will be set to a function that will - // finish the connect process when the attach data or error is received. - connect: { - status: "initialized", - handler: null - }, - connection: null, - - // Used for automated performance tests - connectionTimes: { - "index.loaded": window.indexLoadedTime - }, - keyboardshortcut, - - /** - * The log collector which captures JS console logs for this app. - * @type {LogCollector} - */ - logCollector: null, - - /** - * Indicates if the log collector has been started (it will not be started - * if the welcome page is displayed). - */ - logCollectorStarted : false, - remoteControl, - settings, - translation, - UI +// Used by do_external_connect.js if we receive the attach data after +// connect was already executed. status property can be "initialized", +// "ready" or "connecting". We are interested in "ready" status only which +// means that connect was executed but we have to wait for the attach data. +// In status "ready" handler property will be set to a function that will +// finish the connect process when the attach data or error is received. +export const connect = { + status: "initialized", + handler: null }; +export let connection = null; + +// Used for automated performance tests +export const connectionTimes = { + "index.loaded": window.indexLoadedTime +}; + +/** + * The log collector which captures JS console logs for this app. + * @type {LogCollector} + */ +export let logCollector = null; + +/** + * Indicates if the log collector has been started (it will not be started + * if the welcome page is displayed). + */ +export let logCollectorStarted = false; + // TODO The execution of the mobile app starts from react/index.native.js. // Similarly, the execution of the Web app should start from react/index.web.js // for the sake of consistency and ease of understanding. Temporarily though @@ -76,5 +67,3 @@ const APP = { // the execution of the Web app to start from app.js in order to reduce the // complexity of the beginning step. import './react'; - -module.exports = APP; diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index a2e40867b..44cf2b781 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -145,7 +145,7 @@ function generateURL(domain, options = {}) { /** * The IFrame API interface class. */ -class JitsiMeetExternalAPI extends EventEmitter { +export default class JitsiMeetExternalAPI extends EventEmitter { /** * Constructs new API instance. Creates iframe and loads Jitsi Meet in it. * @@ -424,5 +424,3 @@ class JitsiMeetExternalAPI extends EventEmitter { eventList.forEach(event => this.removeEventListener(event)); } } - -module.exports = JitsiMeetExternalAPI; diff --git a/modules/API/external/index.js b/modules/API/external/index.js new file mode 100644 index 000000000..7591e6fdc --- /dev/null +++ b/modules/API/external/index.js @@ -0,0 +1,3 @@ +// For legacy purposes, preserve the UMD of the public API of Jitsi Meet +// external API (a.k.a. JitsiMeetExternalAPI). +module.exports = require('./external_api').default; diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 92b136a5b..226740cc2 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -8,6 +8,8 @@ import Chat from "./side_pannels/chat/Chat"; import SidePanels from "./side_pannels/SidePanels"; import Avatar from "./avatar/Avatar"; import SideContainerToggler from "./side_pannels/SideContainerToggler"; +import JitsiPopover from "./util/JitsiPopover"; +import messageHandler from "./util/MessageHandler"; import UIUtil from "./util/UIUtil"; import UIEvents from "../../service/UI/UIEvents"; import EtherpadManager from './etherpad/Etherpad'; @@ -19,7 +21,7 @@ import Filmstrip from "./videolayout/Filmstrip"; import SettingsMenu from "./side_pannels/settings/SettingsMenu"; import Profile from "./side_pannels/profile/Profile"; import Settings from "./../settings/Settings"; -import UIErrors from './UIErrors'; +import { FEEDBACK_REQUEST_IN_PROGRESS } from './UIErrors'; import { debounce } from "../util/helpers"; import { updateDeviceList } from '../../react/features/base/devices'; @@ -41,9 +43,7 @@ import { } from '../../react/features/toolbox'; var EventEmitter = require("events"); -UI.messageHandler = require("./util/MessageHandler"); -var messageHandler = UI.messageHandler; -var JitsiPopover = require("./util/JitsiPopover"); +UI.messageHandler = messageHandler; import Feedback from "./feedback/Feedback"; import FollowMe from "../FollowMe"; @@ -1033,7 +1033,7 @@ UI.updateDTMFSupport */ UI.requestFeedbackOnHangup = function () { if (Feedback.isVisible()) - return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS); + return Promise.reject(FEEDBACK_REQUEST_IN_PROGRESS); // Feedback has been submitted already. else if (Feedback.isEnabled() && Feedback.isSubmitted()) { return Promise.resolve({ @@ -1443,4 +1443,6 @@ const UIListeners = new Map([ ] ]); -module.exports = UI; +// TODO: Export every function separately. For now there is no point of doing +// this because we are importing everything. +export default UI; diff --git a/modules/UI/UIErrors.js b/modules/UI/UIErrors.js index b6c6310c7..a7bb03000 100644 --- a/modules/UI/UIErrors.js +++ b/modules/UI/UIErrors.js @@ -1,10 +1,10 @@ /** * A list of all UI errors. */ -module.exports = { - /** - * Indicates that a Feedback request is currently in progress. - * @type {{FEEDBACK_REQUEST_IN_PROGRESS: string}} - */ - FEEDBACK_REQUEST_IN_PROGRESS: "FeedbackRequestInProgress" -}; \ No newline at end of file + +/** + * Indicates that a Feedback request is currently in progress. + * + * @type {{FEEDBACK_REQUEST_IN_PROGRESS: string}} + */ +export const FEEDBACK_REQUEST_IN_PROGRESS = "FeedbackRequestInProgress"; diff --git a/modules/UI/util/JitsiPopover.js b/modules/UI/util/JitsiPopover.js index 3bb226aa3..3717b8f85 100644 --- a/modules/UI/util/JitsiPopover.js +++ b/modules/UI/util/JitsiPopover.js @@ -77,7 +77,7 @@ const positionConfigurations = { } } }; -var JitsiPopover = (function () { +export default (function () { /** * The default options */ @@ -294,5 +294,3 @@ var JitsiPopover = (function () { return JitsiPopover; })(); - -module.exports = JitsiPopover; diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js index b23f5df85..f2fc740e2 100644 --- a/modules/UI/util/MessageHandler.js +++ b/modules/UI/util/MessageHandler.js @@ -504,4 +504,4 @@ var messageHandler = { } }; -module.exports = messageHandler; +export default messageHandler; diff --git a/modules/keyboardshortcut/keyboardshortcut.js b/modules/keyboardshortcut/keyboardshortcut.js index b1b4a26e0..649787f54 100644 --- a/modules/keyboardshortcut/keyboardshortcut.js +++ b/modules/keyboardshortcut/keyboardshortcut.js @@ -82,7 +82,7 @@ let enabled = true; /** * Maps keycode to character, id of popover for given function and function. */ -var KeyboardShortcut = { +const KeyboardShortcut = { init: function () { initGlobalShortcuts(); @@ -273,4 +273,4 @@ var KeyboardShortcut = { } }; -module.exports = KeyboardShortcut; +export default KeyboardShortcut; diff --git a/webpack.config.js b/webpack.config.js index 310a822d0..dc34b071f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -188,7 +188,7 @@ const configs = [ // JitsiMeetExternalAPI). Object.assign({}, config, { entry: { - 'external_api': './modules/API/external/external_api.js' + 'external_api': './modules/API/external/index.js' }, output: Object.assign({}, config.output, { library: 'JitsiMeetExternalAPI'