From 42be5336146a0d7a3d2c448107e3025e2c553928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Mon, 21 May 2018 22:06:55 +0200 Subject: Reorganize source code --- .babelrc | 5 --- .gitignore | 3 +- app/features/app/components/App.js | 32 +++++++++++++ app/features/app/components/index.js | 1 + app/features/app/index.js | 1 + app/features/conference/components/Conference.js | 54 ++++++++++++++++++++++ app/features/conference/components/index.js | 1 + app/features/conference/index.js | 1 + app/features/config/index.js | 12 +++++ app/index.html | 18 ++++++++ app/index.js | 9 ++++ config.js | 6 --- templates/index.html | 19 -------- webpack.config.js | 14 ++++-- windows/jitsi-meet/src/index.js | 57 ------------------------ 15 files changed, 142 insertions(+), 91 deletions(-) delete mode 100644 .babelrc create mode 100644 app/features/app/components/App.js create mode 100644 app/features/app/components/index.js create mode 100644 app/features/app/index.js create mode 100644 app/features/conference/components/Conference.js create mode 100644 app/features/conference/components/index.js create mode 100644 app/features/conference/index.js create mode 100644 app/features/config/index.js create mode 100644 app/index.html create mode 100644 app/index.js delete mode 100644 config.js delete mode 100644 templates/index.html delete mode 100644 windows/jitsi-meet/src/index.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 91ad003..0000000 --- a/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "presets": [ - "react" - ] -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 698d5d9..6efebe2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .sync-config.cson .electron-gyp .npmrc +.idea .DS_Store @@ -14,4 +15,4 @@ npm-debug.log Jitsi Meet* -build/ \ No newline at end of file +build/ diff --git a/app/features/app/components/App.js b/app/features/app/components/App.js new file mode 100644 index 0000000..2afd502 --- /dev/null +++ b/app/features/app/components/App.js @@ -0,0 +1,32 @@ +import React, { Component } from 'react'; + +import { Conference } from '../../conference'; +import config from '../../config'; + +/** + * Main component encapsulating the entire application. + */ +export default class App extends Component { + /** + * Initializes a new {@code App} instance. + * + * @inheritdoc + */ + constructor() { + super(); + + document.title = config.appName; + } + + /** + * Implements React's {@link Component#render()}. + * + * @inheritdoc + * @returns {ReactElement} + */ + render() { + return ( + + ); + } +} diff --git a/app/features/app/components/index.js b/app/features/app/components/index.js new file mode 100644 index 0000000..c866729 --- /dev/null +++ b/app/features/app/components/index.js @@ -0,0 +1 @@ +export { default as App } from './App'; diff --git a/app/features/app/index.js b/app/features/app/index.js new file mode 100644 index 0000000..07635cb --- /dev/null +++ b/app/features/app/index.js @@ -0,0 +1 @@ +export * from './components'; diff --git a/app/features/conference/components/Conference.js b/app/features/conference/components/Conference.js new file mode 100644 index 0000000..e77ece9 --- /dev/null +++ b/app/features/conference/components/Conference.js @@ -0,0 +1,54 @@ +import { Component } from 'react'; + +import { + RemoteControl, + setupScreenSharingForWindow, + setupAlwaysOnTopRender, + setupWiFiStats +} from 'jitsi-meet-electron-utils'; + +import config from '../../config'; + +/** + * Jitsi Meet Window Component + */ +export default class Conference extends Component { + /** + * Attach the script + */ + componentDidMount() { + const script = document.createElement('script'); + + script.async = true; + script.onload = this._onScriptLoad; + script.onerror = console.error; + script.src = `https://${config.defaultDomain}/external_api.js`; + + document.head.appendChild(script); + } + + + /** + * Render function of component. + * + * @return {ReactElement} + */ + render() { + return null; + } + + /** + * When the script is loaded attach utils from jitsi-meet-electron-utils + */ + _onScriptLoad() { + const JitsiMeetExternalAPI = window.JitsiMeetExternalAPI; + + const api = new JitsiMeetExternalAPI(config.defaultDomain); + const iframe = api.getIFrame(); + + setupScreenSharingForWindow(iframe); + new RemoteControl(iframe); + setupAlwaysOnTopRender(api); + setupWiFiStats(iframe); + } +} diff --git a/app/features/conference/components/index.js b/app/features/conference/components/index.js new file mode 100644 index 0000000..7ee56f5 --- /dev/null +++ b/app/features/conference/components/index.js @@ -0,0 +1 @@ +export { default as Conference } from './Conference'; diff --git a/app/features/conference/index.js b/app/features/conference/index.js new file mode 100644 index 0000000..07635cb --- /dev/null +++ b/app/features/conference/index.js @@ -0,0 +1 @@ +export * from './components'; diff --git a/app/features/config/index.js b/app/features/config/index.js new file mode 100644 index 0000000..22d3806 --- /dev/null +++ b/app/features/config/index.js @@ -0,0 +1,12 @@ + +export default { + /** + * Application name. + */ + appName: 'Jitsi Meet', + + /** + * The domain of the Jitsi Meet deployment that will be used. + */ + defaultDomain: 'meet.jit.si' +}; diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..befc6f9 --- /dev/null +++ b/app/index.html @@ -0,0 +1,18 @@ + + + + + + +
+ + diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..968cd0f --- /dev/null +++ b/app/index.js @@ -0,0 +1,9 @@ +import React from 'react'; +import { render } from 'react-dom'; + +import { App } from './features/app'; + +/** + * Render the main / root application. + */ +render(, document.getElementById('app')); diff --git a/config.js b/config.js deleted file mode 100644 index 73d54c3..0000000 --- a/config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - /** - * The domain of the Jitsi Meet deployment that will be used. - */ - jitsiMeetDomain: 'meet.jit.si' -}; diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index 48f1288..0000000 --- a/templates/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - diff --git a/webpack.config.js b/webpack.config.js index 4d6ac55..1d2bea9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,6 +15,15 @@ const commonConfig = { { exclude: /(node_modules)/, loader: 'babel-loader', + options: { + presets: [ + [ + require.resolve('babel-preset-env'), + { modules: false } + ], + require.resolve('babel-preset-react') + ] + }, test: /\.js$/ }, { @@ -41,11 +50,10 @@ module.exports = [ commonConfig), Object.assign({ target: 'electron-renderer', - entry: { renderer: './windows/jitsi-meet/src/index.js' }, + entry: { renderer: './app/index.js' }, plugins: [ new HtmlWebpackPlugin({ - title: 'Jitsi Meet', - template: path.resolve('./templates/index.html') + template: './app/index.html' }) ] }, diff --git a/windows/jitsi-meet/src/index.js b/windows/jitsi-meet/src/index.js deleted file mode 100644 index b7d7e36..0000000 --- a/windows/jitsi-meet/src/index.js +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import { render } from 'react-dom'; - -import { - RemoteControl, - setupScreenSharingForWindow, - setupAlwaysOnTopRender, - setupWiFiStats -} from 'jitsi-meet-electron-utils'; - -import { jitsiMeetDomain } from '../../../config.js'; - -/** - * Jitsi Meet Window Component - */ -class JitsiMeetWindow extends React.Component { - - /** - * Render function of component - * @return {ScriptElement} - */ - render() { - return null; - } - - /** - * Attach the script - */ - componentDidMount() { - - const script = document.createElement('script'); - - script.async = true; - script.onload = this._onScriptLoad; - script.onerror = console.error; - script.src = `https://${jitsiMeetDomain}/external_api.js`; - - document.head.appendChild(script); - } - - /** - * When the script is loaded attach utils from jitsi-meet-electron-utils - */ - _onScriptLoad() { - const JitsiMeetExternalAPI = window.JitsiMeetExternalAPI; - - const api = new JitsiMeetExternalAPI(jitsiMeetDomain); - const iframe = api.getIFrame(); - - setupScreenSharingForWindow(iframe); - new RemoteControl(iframe); - setupAlwaysOnTopRender(api); - setupWiFiStats(iframe); - } -} - -render(, document.getElementById('app')); -- cgit v1.2.3